Has anyone been able to compile a plugin that would be able to access gnome-contacts SIP-phone numbers?
Gnome calls probably already has the code needed to access gnome-contacts phone numbers. Maybe the code can be reused.
Gnome Contacts seems to use vCard 3.0 and does not support any specific SIP/SIPS field that would export like IMPP:sip or IMPP:sips. Gnome contacts allows Telephone field Other to hold text which is exported as TEL;TYPE=VOICE:demouser12@sip.domain.org.
There is a possibility to use LibreOffice Base to manipulate friends.db. To make it possible, you will need an OBDC driver for SQLite3 and specify the path to friends.db.
Note: Writing Database=$HOME/.local/share/linphone/friends.db will not work. Absolute and relative paths work, no variables.
Open program lobase or find LibreOffice Base in the application menu. Select:
Connect to an existing database: ODBC
Next
Name of the ODBC data source: Click Browse button
Select: linphone contacts
Next
Click Test connection button. It should display a pop-up with "The connection was established successfully."
Click Finish button.
Save as Linphone.odb
You should now be able to see table friends and table friends_lists
Modifications may require restart of Linphone before changes are seen in the contacts section since there is no reload-contacts-from-database-button.
Using DB_Browser_for_SQLite-v3 (AppImage) to modify friends.db
There is a user friendly SQLite database tool called DB Browser for SQLite that can be used to modify friends.db
vCard import example
You can probably export contacts in vCard format from your current contact app. The SIP-phone field is often not exported. Links to contact avatars are sometimes exported, which would make it possible to populate Linphone with the same hard copy avatars (no dynamic link is possible). Some cleaning and renaming of the fields will probably be needed to allow Linphone import. Linphone uses ROLE field for company name.
Create vCard contact(s) in file contacts.vcf that looks like this:
Alternatively, a completely clean database without headers can be recreated with importing the full export previously made with command (all columns including id):
The tool exports a vCard that looks like this with all fields set:
BEGIN:VCARD
VERSION:4.0
FN:Test vCardUser Three
IMPP:sips:test.vcarduser.three@sip.linphone.org
IMPP:sips:+125@sip.linphone.org
PHOTO:linphone-desktop:/avatar.svg
ROLE:CompanyNameC
EMAIL:test.vcarduser.three@private.mail.org
EMAIL:info@mail.companynamec.org
URL:https://www.companynamec.org
ADR:;;Third Street 3C;NeighborhoodC;;123 48 Smalltown;UnspecifiedCountryC U
nspecifiedContinentC
END:VCARD
TO CHECK: automatic update from gnome-contacts
It should (in theory) be possible to use an automatic flow of regularily updating linphone contacts with whatever gnome-contacts gathers from online sources:
gnome-contacts -> merge contact lists from online sources -> export as vCard -> clean the vCard with cleaning script and format as vCard 4.0 using tools such as python3 tool VCF_contacts_merger with GUI and perl tool Text-vCard-Precisely capable of dealing with v4.0 as well as python3 library vobject for vCard 3.0 but able to output fields also used in v4.0 -> use cron service with help of linphone-contacts-vcard-csv-import-export tools to regularily (or trigger based) update linphone contacts.
Has anyone been able to compile a plugin that would be able to access
gnome-contacts
SIP-phone numbers?Gnome calls probably already has the code needed to access
gnome-contacts
phone numbers. Maybe the code can be reused.Gnome Contacts seems to use vCard 3.0 and does not support any specific SIP/SIPS field that would export like
IMPP:sip
orIMPP:sips
. Gnome contacts allows Telephone field Other to hold text which is exported asTEL;TYPE=VOICE:demouser12@sip.domain.org
.A workaround would be to access
friends.db
SQLite3 database. See also this guide and also this other guide aimed at gnome-contacts SQLite3 database.Connecting LibreOffice Base to
friends.db
There is a possibility to use LibreOffice Base to manipulate
friends.db
. To make it possible, you will need an OBDC driver for SQLite3 and specify the path tofriends.db
.sqliteobdc
on different linux distributionsOnce
sqliteobdc
is installed, there will be a file*odbc.ini
orodbcinst.ini
somewhere on the system. Here some examples:This file contains:
Now we have to specify the path to linphone contact database in
$HOME/.local/share/linphone/friends.db
Create file
$HOME/.odbc.ini
with the following content.SQLITE3
refers to fileodbcinst.ini
:Note: Writing
Database=$HOME/.local/share/linphone/friends.db
will not work. Absolute and relative paths work, no variables.lobase
or findLibreOffice Base
in the application menu. Select:ODBC
Browse
buttonlinphone contacts
Test connection
button. It should display a pop-up with "The connection was established successfully."Finish
button.Linphone.odb
You should now be able to see table
friends
and tablefriends_lists
Modifications may require restart of Linphone before changes are seen in the contacts section since there is no reload-contacts-from-database-button.
Using
DB_Browser_for_SQLite-v3 (AppImage)
to modifyfriends.db
There is a user friendly SQLite database tool called
DB Browser for SQLite
that can be used to modifyfriends.db
vCard import example
You can probably export contacts in vCard format from your current contact app. The SIP-phone field is often not exported. Links to contact avatars are sometimes exported, which would make it possible to populate Linphone with the same hard copy avatars (no dynamic link is possible). Some cleaning and renaming of the fields will probably be needed to allow Linphone import. Linphone uses
ROLE
field for company name.Create vCard contact(s) in file
contacts.vcf
that looks like this:Add two square avatars of choice to directory
$HOME/.local/share/linphone/avatars
to test with, one PNG and one JPEG named as the following:a.png
b.jpg
Create an import script, for instance this PHP-script
add_contacts_with_vcard_data.php
that can be run locally, adapted from this source:Install the package that has file
/usr/bin/php
for your linux distribution. For instance for openSUSE Tumbleweed:zypper install php8-cli
Start the import script.
php -S 127.0.0.1:8000 add_contacts_with_vcard_data.php
Open the address in a webbrowser to create the import by hitting refresh (often
F5
button works as well to refresh):xdg-open "http://127.0.0.1:8000/"
Restart Linphone and see if the contacts were imported.
SQL statement to insert new contact
sqlite3 $HOME/.local/share/linphone/friends.db "INSERT INTO friends (friend_list_id, sip_uri, subscribe_policy, send_subscribe, ref_key, vCard, vCard_etag, vCard_url, presence_received) VALUES (1, 'sips:+12345@sip.tel.org', 1, 0, NULL, 'BEGIN:VCARD' || char(10) || 'VERSION:4.0' || char(10) || 'IMPP:sips:+12345@sip.tel.org' || char(10) || 'FN:Demo12345' || char(10) || 'IMPP:sips:+12345@1.2.3.4' || char(10) || 'END:VCARD', NULL, NULL, 0);" ".exit"
Test files
contacts.csv contacts_lists.csv
add_contacts.csv add_contacts_lists.csv
Export contacts from
friends.db
Create at lease one contact with multiple fields in Linphone.
Full export:
Only contacts export with headers (without column
id
):contacts.csv
with header (without columnid
) would look like this:Only contacts export without headers (without column
id
):Import contacts into
friends.db
Make sure
friends.db
is empty.Restart Linphone to recreate the database headers.
Alternatively, you can reset all your personal Linphone settings with
rm -rf $HOME/.config/linphone $HOME/.local/share/linphone
and restart
linphone
to re-create all default settings.Then import the previously exported contacts.
Populate database with new contacts (without id column) assuming that table
friends_lists
already exists with the following data on row where id=1:sqlite3 $DATABASE "INSERT INTO friends_lists (id, display_name, rls_uri, uri, revision) VALUES (1, '_default', NULL, NULL, 0);" ".exit"
Executing the above SQL statement will cause an error if row id=1 already exists.
Alternatively, a completely clean database without headers can be recreated with importing the full export previously made with command (all columns including id):
Import additional contacts into
friends.db
Assuming there is a header row which will be skipped.
Restart
linphone
if you don't yet see any of the imported contacts.python3 and bash import export script
It seems that the
gnome-contacts-vcard-importer
python script could be adapted to Linphone vCard import. The avatars import/export would have to be dealt with separately.Experimental tools to modify linphone contact database which include:
backup tar.xz archive with vCard, csv, (only used) avatars/*
vCard format
SQLITE3 csv format
The tool exports a vCard that looks like this with all fields set:
TO CHECK: automatic update from gnome-contacts
It should (in theory) be possible to use an automatic flow of regularily updating linphone contacts with whatever gnome-contacts gathers from online sources:
gnome-contacts
-> merge contact lists from online sources -> export as vCard -> clean the vCard with cleaning script and format as vCard 4.0 using tools such as python3 toolVCF_contacts_merger
with GUI and perl tool Text-vCard-Precisely capable of dealing with v4.0 as well as python3 library vobject for vCard 3.0 but able to output fields also used in v4.0 -> usecron
service with help oflinphone-contacts-vcard-csv-import-export
tools to regularily (or trigger based) update linphone contacts.