From f934c5b59f2fe2c3c00a50135add4aec55ac4024 Mon Sep 17 00:00:00 2001 From: Marouane L Date: Tue, 6 Sep 2022 17:29:07 +0100 Subject: Add vCard support Only nicknames, photos, birthdays, addresses, telephone numbers, emails, JIDs, titles, roles, notes, and URLs are supported Due to the synopsis array not having enough space, `/vcard photo open-self` and `/vcard photo save-self` are not documented properly in the synopsis section of the `/vcard` command, but they are documented in the arguments section Fixed memory leak in vcard autocomplete (thanks to debXwoody) --- src/command/cmd_defs.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 5 deletions(-) (limited to 'src/command/cmd_defs.c') diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 91346fce..4263ac22 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1268,7 +1268,8 @@ static struct cmd_t command_defs[] = { "/time all|console|chat|muc|config|private|xml off", "/time statusbar set ", "/time statusbar off", - "/time lastactivity set ") + "/time lastactivity set ", + "/time vcard set ") CMD_DESC( "Configure time display preferences. " "Time formats are strings supported by g_date_time_format. " @@ -1291,7 +1292,8 @@ static struct cmd_t command_defs[] = { { "statusbar set ", "Change time format in statusbar." }, { "statusbar off", "Do not show time in status bar." }, { "lastactivity set ", "Change time format for last activity." }, - { "all set ", "Set time for: console, chat, muc, config, private and xml windows." }, + { "vcard set ", "Change the time format used to display time/dates in vCard (such as birthdays)" }, + { "all set ", "Set time for: console, chat, muc, config, private, and xml windows." }, { "all off", "Do not show time for: console, chat, muc, config, private and xml windows." }) CMD_EXAMPLES( "/time console set %H:%M:%S", @@ -1582,6 +1584,124 @@ static struct cmd_t command_defs[] = { "/autoconnect off") }, + { "/vcard", + parse_args, 0, 7, NULL, + CMD_SUBFUNCS( + {"add", cmd_vcard_add}, + {"remove", cmd_vcard_remove}, + {"get", cmd_vcard_get}, + {"set", cmd_vcard_set}, + {"photo", cmd_vcard_photo}, + {"refresh", cmd_vcard_refresh}, + {"save", cmd_vcard_save}) + CMD_MAINFUNC(cmd_vcard) + CMD_TAGS( + CMD_TAG_CHAT, + CMD_TAG_GROUPCHAT) + CMD_SYN( + "/vcard get []", + "/vcard photo open []", + "/vcard photo save [output ] [index ]", + "/vcard set fullname ", + "/vcard set name family ", + "/vcard set name given ", + "/vcard set name middle ", + "/vcard set name prefix ", + "/vcard set name suffix ", + "/vcard set []", + "/vcard set pobox ", + "/vcard set extaddr ", + "/vcard set street ", + "/vcard set locality ", + "/vcard set region ", + "/vcard set pocode ", + "/vcard set country ", + "/vcard set type domestic|international", + "/vcard set home on|off", + "/vcard set work on|off", + "/vcard set voice on|off", + "/vcard set fax on|off", + "/vcard set pager on|off", + "/vcard set msg on|off", + "/vcard set cell on|off", + "/vcard set video on|off", + "/vcard set bbs on|off", + "/vcard set modem on|off", + "/vcard set isdn on|off", + "/vcard set pcs on|off", + "/vcard set preferred on|off", + "/vcard set parcel on|off", + "/vcard set postal on|off", + "/vcard set internet on|off", + "/vcard set x400 on|off", + "/vcard add nickname ", + "/vcard add birthday ", + "/vcard add address", + "/vcard add tel ", + "/vcard add email ", + "/vcard add jid ", + "/vcard add title ", + "/vcard add role <role>", + "/vcard add note <note>", + "/vcard add url <url>", + "/vcard remove <index>", + "/vcard refresh", + "/vcard save") + CMD_DESC( + "Read your vCard or a user's vCard, get a user's avatar via their vCard, or modify your vCard. If no arguments are given, your vCard will be displayed in a new window, or an existing vCard window.") + CMD_ARGS( + { "get [<nick|contact>]", "Get your vCard, if a nickname/contact is provided, get that user's vCard" }, + { "photo open <nick|contact> [<index>]", "Download a user's photo from their vCard to a file, and open it. If index is not specified, download the first photo (usually avatar) from their vCard" }, + { "photo save <nick|contact>", "Download a user's photo from their vCard to a file. If index is not specified, download the first photo (usually avatar) from their vCard. If output is not specified, download the photo to profanity's photos directory." }, + { "photo open-self [<index>]", "Download a photo from your vCard to a file, and open it. If index is not specified, download the first photo (usually avatar) from your vCard" }, + { "photo save-self", "Download a photo from your vCard to a file. If index is not specified, download the first photo (usually avatar) from your vCard. If output is not specified, download the photo to profanity's photos directory. Same arguments as `photo open`" }, + { "set fullname <fullname>", "Set your vCard's fullname to the specified value" }, + { "set name family <family>", "Set your vCard's family name to the specified value" }, + { "set name given <given>", "Set your vCard's given name to the specified value" }, + { "set name middle <middle>", "Set your vCard's middle name to the specified value" }, + { "set name prefix <prefix>", "Set your vCard's prefix name to the specified value" }, + { "set name suffix <suffix>", "Set your vCard's suffix name to the specified value" }, + { "set <index> [<value>]", "Set the main field in a element in your vCard to the specified value, or if no value was specified, modify the field in an editor, This only works in elements that have one field." }, + { "set <index> pobox <value>", "Set the P.O. box in an address element in your vCard to the specified value." }, + { "set <index> extaddr <value>", "Set the extended address in an address element in your vCard to the specified value." }, + { "set <index> street <value>", "Set the street in an address element in your vCard to the specified value." }, + { "set <index> locality <value>", "Set the locality in an address element in your vCard to the specified value." }, + { "set <index> region <value>", "Set the region in an address element in your vCard to the specified value." }, + { "set <index> pocode <value>", "Set the P.O. code in an address element in your vCard to the specified value." }, + { "set <index> type domestic|international", "Set the type in an address element in your vCard to either domestic or international." }, + { "set <index> home on|off", "Set the home option in an element in your vCard. (address, telephone, e-mail only)" }, + { "set <index> work on|off", "Set the work option in an element in your vCard. (address, telephone, e-mail only)" }, + { "set <index> voice on|off", "Set the voice option in a telephone element in your vCard." }, + { "set <index> fax on|off", "Set the fax option in a telephone element in your vCard." }, + { "set <index> pager on|off", "Set the pager option in a telephone element in your vCard." }, + { "set <index> msg on|off", "Set the message option in a telephone element in your vCard." }, + { "set <index> cell on|off", "Set the cellphone option in a telephone element in your vCard." }, + { "set <index> video on|off", "Set the video option in a telephone element in your vCard." }, + { "set <index> bbs on|off", "Set the BBS option in a telephone element in your vCard." }, + { "set <index> modem on|off", "Set the modem option in a telephone element in your vCard." }, + { "set <index> isdn on|off", "Set the ISDN option in a telephone element in your vCard." }, + { "set <index> pcs on|off", "Set the PCS option in a telephone element in your vCard." }, + { "set <index> preferred on|off", "Set the preferred option in an element in your vCard. (address, telephone, e-mail only)" }, + { "set <index> parcel on|off", "Set the parcel option in an address element in your vCard." }, + { "set <index> postal on|off", "Set the postal option in an address element in your vCard." }, + { "set <index> internet on|off", "Set the internet option in an e-mail address in your vCard." }, + { "set <index> x400 on|off", "Set the X400 option in an e-mail address in your vCard." }, + { "add nickname <nickname>", "Add a nickname to your vCard" }, + { "add birthday <date>", "Add a birthday date to your vCard" }, + { "add address", "Add an address to your vCard" }, + { "add tel <number>", "Add a telephone number to your vCard" }, + { "add email <userid>", "Add an e-mail address to your vCard" }, + { "add jid <jid>", "Add a Jabber ID to your vCard" }, + { "add title <title>", "Add a title to your vCard" }, + { "add role <role>", "Add a role to your vCard" }, + { "add note <note>", "Add a note to your vCard" }, + { "add url <url>", "Add a URL to your vCard" }, + { "remove <index>", "Remove a element in your vCard by index" }, + { "refresh", "Refreshes the local copy of the current account's vCard (undoes all your unpublished modifications)" }, + { "save", "Save changes to the server" }) + CMD_NOEXAMPLES + }, + { "/vercheck", parse_args, 0, 1, NULL, CMD_NOSUBFUNCS @@ -2559,7 +2679,8 @@ static struct cmd_t command_defs[] = { { "avatar", cmd_executable_avatar }, { "urlopen", cmd_executable_urlopen }, { "urlsave", cmd_executable_urlsave }, - { "editor", cmd_executable_editor }) + { "editor", cmd_executable_editor }, + { "vcard_photo", cmd_executable_vcard_photo }) CMD_NOMAINFUNC CMD_TAGS( CMD_TAG_DISCOVERY) @@ -2568,7 +2689,9 @@ static struct cmd_t command_defs[] = { "/executable urlopen set <cmdtemplate>", "/executable urlopen default", "/executable urlsave set <cmdtemplate>", - "/executable urlsave default") + "/executable urlsave default", + "/executable vcard_photo set <cmdtemplate>", + "/executable vcard_photo default") CMD_DESC( "Configure executable that should be called upon a certain command.") CMD_ARGS( @@ -2577,7 +2700,9 @@ static struct cmd_t command_defs[] = { { "urlopen default", "Restore to default settings." }, { "urlsave set", "Set executable that is run by /url save. Takes a command template that replaces %u and %p with the URL and path respectively." }, { "urlsave default", "Use the built-in download method for saving." }, - { "editor set", "Set editor to be used with /editor. Needs a terminal editor or a script to run a graphical editor." }) + { "editor set", "Set editor to be used with /editor. Needs a terminal editor or a script to run a graphical editor." }, + { "vcard_photo set", "Set executable that is run by /vcard photo open. Takes a command template that replaces %p with the path" }, + { "vcard_photo default", "Restore to default settings." }) CMD_EXAMPLES( "/executable avatar xdg-open", "/executable urlopen set \"xdg-open %u\"", @@ -2586,6 +2711,7 @@ static struct cmd_t command_defs[] = { "/executable urlsave set \"wget %u -O %p\"", "/executable urlsave set \"curl %u -o %p\"", "/executable urlsave default", + "/executable vcard_photo set \"feh %p\"", "/executable editor set vim") }, -- cgit 1.4.1-2-gfad0