Ring Daemon
Loading...
Searching...
No Matches
vcard.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <string>
20#include <string_view>
21#include <map>
22#include <filesystem>
23
24namespace jami {
25namespace vCard {
26
28{
29 constexpr static std::string_view SEPARATOR_TOKEN = ";";
30 constexpr static std::string_view END_LINE_TOKEN = "\n";
31 constexpr static std::string_view BEGIN_TOKEN = "BEGIN:VCARD";
32 constexpr static std::string_view END_TOKEN = "END:VCARD";
33 constexpr static std::string_view BEGIN_TOKEN_KEY = "BEGIN";
34 constexpr static std::string_view END_TOKEN_KEY = "END";
35};
36;
37
39{
40 constexpr static std::string_view UID = "UID";
41 constexpr static std::string_view VCARD_VERSION = "VERSION";
42 constexpr static std::string_view ADDRESS = "ADR";
43 constexpr static std::string_view AGENT = "AGENT";
44 constexpr static std::string_view BIRTHDAY = "BDAY";
45 constexpr static std::string_view CATEGORIES = "CATEGORIES";
46 constexpr static std::string_view CLASS = "CLASS";
47 constexpr static std::string_view DELIVERY_LABEL = "LABEL";
48 constexpr static std::string_view EMAIL = "EMAIL";
49 constexpr static std::string_view FORMATTED_NAME = "FN";
50 constexpr static std::string_view GEOGRAPHIC_POSITION = "GEO";
51 constexpr static std::string_view KEY = "KEY";
52 constexpr static std::string_view LOGO = "LOGO";
53 constexpr static std::string_view MAILER = "MAILER";
54 constexpr static std::string_view NAME = "N";
55 constexpr static std::string_view NICKNAME = "NICKNAME";
56 constexpr static std::string_view DESCRIPTION = "DESCRIPTION";
57 constexpr static std::string_view NOTE = "NOTE";
58 constexpr static std::string_view ORGANIZATION = "ORG";
59 constexpr static std::string_view PHOTO = "PHOTO";
60 constexpr static std::string_view PRODUCT_IDENTIFIER = "PRODID";
61 constexpr static std::string_view REVISION = "REV";
62 constexpr static std::string_view ROLE = "ROLE";
63 constexpr static std::string_view SORT_STRING = "SORT-STRING";
64 constexpr static std::string_view SOUND = "SOUND";
65 constexpr static std::string_view TELEPHONE = "TEL";
66 constexpr static std::string_view TIME_ZONE = "TZ";
67 constexpr static std::string_view TITLE = "TITLE";
68 constexpr static std::string_view RDV_ACCOUNT = "RDV_ACCOUNT";
69 constexpr static std::string_view RDV_DEVICE = "RDV_DEVICE";
70 constexpr static std::string_view URL = "URL";
71 constexpr static std::string_view BASE64 = "ENCODING=BASE64";
72 constexpr static std::string_view TYPE_PNG = "TYPE=PNG";
73 constexpr static std::string_view TYPE_JPEG = "TYPE=JPEG";
74 constexpr static std::string_view PHOTO_PNG = "PHOTO;ENCODING=BASE64;TYPE=PNG";
75 constexpr static std::string_view PHOTO_JPEG = "PHOTO;ENCODING=BASE64;TYPE=JPEG";
76};
77
78struct Value
79{
80 constexpr static std::string_view TITLE = "title";
81 constexpr static std::string_view DESCRIPTION = "description";
82 constexpr static std::string_view AVATAR = "avatar";
83 constexpr static std::string_view RDV_ACCOUNT = "rdvAccount";
84 constexpr static std::string_view RDV_DEVICE = "rdvDevice";
85};
86
87namespace utils {
88
89using VCardData = std::map<std::string, std::string, std::less<>>;
90
96VCardData toMap(std::string_view content);
98std::string toString(const VCardData& vCard);
99void removeByKey(VCardData& vCard, std::string_view key);
100void save(const VCardData& vCard, const std::filesystem::path& path, const std::filesystem::path& pathLink);
101
102} // namespace utils
103
104} // namespace vCard
105} // namespace jami
void removeByKey(VCardData &vCard, std::string_view key)
Definition vcard.cpp:101
std::map< std::string, std::string, std::less<> > VCardData
Definition vcard.h:89
std::string toString(const VCardData &vCard)
Definition vcard.cpp:58
VCardData toMap(std::string_view content)
Payload to vCard.
Definition vcard.cpp:31
void save(const VCardData &vCard, const std::filesystem::path &path, const std::filesystem::path &pathLink)
Definition vcard.cpp:87
VCardData initVcard()
Definition vcard.cpp:48
void emitSignal(Args... args)
Definition jami_signal.h:64
static constexpr std::string_view SEPARATOR_TOKEN
Definition vcard.h:29
static constexpr std::string_view END_LINE_TOKEN
Definition vcard.h:30
static constexpr std::string_view BEGIN_TOKEN
Definition vcard.h:31
static constexpr std::string_view BEGIN_TOKEN_KEY
Definition vcard.h:33
static constexpr std::string_view END_TOKEN
Definition vcard.h:32
static constexpr std::string_view END_TOKEN_KEY
Definition vcard.h:34
static constexpr std::string_view ADDRESS
Definition vcard.h:42
static constexpr std::string_view LOGO
Definition vcard.h:52
static constexpr std::string_view CATEGORIES
Definition vcard.h:45
static constexpr std::string_view PHOTO_JPEG
Definition vcard.h:75
static constexpr std::string_view NOTE
Definition vcard.h:57
static constexpr std::string_view AGENT
Definition vcard.h:43
static constexpr std::string_view TELEPHONE
Definition vcard.h:65
static constexpr std::string_view TYPE_JPEG
Definition vcard.h:73
static constexpr std::string_view SORT_STRING
Definition vcard.h:63
static constexpr std::string_view URL
Definition vcard.h:70
static constexpr std::string_view TITLE
Definition vcard.h:67
static constexpr std::string_view PHOTO
Definition vcard.h:59
static constexpr std::string_view EMAIL
Definition vcard.h:48
static constexpr std::string_view TIME_ZONE
Definition vcard.h:66
static constexpr std::string_view RDV_ACCOUNT
Definition vcard.h:68
static constexpr std::string_view BASE64
Definition vcard.h:71
static constexpr std::string_view BIRTHDAY
Definition vcard.h:44
static constexpr std::string_view VCARD_VERSION
Definition vcard.h:41
static constexpr std::string_view NICKNAME
Definition vcard.h:55
static constexpr std::string_view CLASS
Definition vcard.h:46
static constexpr std::string_view DELIVERY_LABEL
Definition vcard.h:47
static constexpr std::string_view PRODUCT_IDENTIFIER
Definition vcard.h:60
static constexpr std::string_view MAILER
Definition vcard.h:53
static constexpr std::string_view ROLE
Definition vcard.h:62
static constexpr std::string_view UID
Definition vcard.h:40
static constexpr std::string_view PHOTO_PNG
Definition vcard.h:74
static constexpr std::string_view ORGANIZATION
Definition vcard.h:58
static constexpr std::string_view KEY
Definition vcard.h:51
static constexpr std::string_view SOUND
Definition vcard.h:64
static constexpr std::string_view RDV_DEVICE
Definition vcard.h:69
static constexpr std::string_view GEOGRAPHIC_POSITION
Definition vcard.h:50
static constexpr std::string_view DESCRIPTION
Definition vcard.h:56
static constexpr std::string_view FORMATTED_NAME
Definition vcard.h:49
static constexpr std::string_view REVISION
Definition vcard.h:61
static constexpr std::string_view NAME
Definition vcard.h:54
static constexpr std::string_view TYPE_PNG
Definition vcard.h:72
static constexpr std::string_view TITLE
Definition vcard.h:80
static constexpr std::string_view DESCRIPTION
Definition vcard.h:81
static constexpr std::string_view RDV_DEVICE
Definition vcard.h:84
static constexpr std::string_view RDV_ACCOUNT
Definition vcard.h:83
static constexpr std::string_view AVATAR
Definition vcard.h:82