Debian Codegraph @

Dekko/backend/utils/serviceutils.h

raw symbols SCIP
1 #ifndef SERVICEUTILS_H
2 #define SERVICEUTILS_H
3
4 #include <QByteArray>
5 #include <QDataStream>
6 #include <qmailaccountkey.h>
7 #include <qmailaccountsortkey.h>
8 #include <qmailfolderkey.h>
9 #include <qmailfoldersortkey.h>
10 #include <qmailmessagekey.h>
11 #include <qmailmessagesortkey.h>
12
13 inline QMailMessageKey to_msg_key(const QByteArray &key) {
14 QMailMessageKey mKey;
15 QByteArray m = key;
16 QDataStream keystream(&m, QIODevice::ReadWrite);
17 mKey.deserialize(keystream);
18 return mKey;
19 }
20
21 inline QByteArray msg_key_bytes(const QMailMessageKey &key) {
22 QByteArray msgKey;
23 QDataStream keystream(&msgKey, QIODevice::WriteOnly);
24
25 key.serialize(keystream);
26 return msgKey;
27 }
28
29 inline QMailMessageSortKey to_msg_sort_key(const QByteArray &key) {
30 QMailMessageSortKey sKey;
31 QByteArray s = key;
32 QDataStream skeystream(&s, QIODevice::ReadWrite);
33 sKey.deserialize(skeystream);
34 return sKey;
35 }
36
37 inline QByteArray msg_sort_key_bytes(const QMailMessageSortKey &key) {
38 QByteArray sortKey;
39 QDataStream keystream(&sortKey, QIODevice::WriteOnly);
40
41 key.serialize(keystream);
42
43 return sortKey;
44 }
45
46 inline QMailMessageIdList from_dbus_msglist(const QList<quint64> &ids) {
47 QMailMessageIdList list;
48 foreach(const quint64 &id, ids) {
49 QMailMessageId msgId(id);
50 list << msgId;
51 }
52 return list;
53 }
54
55 inline QList<quint64> to_dbus_msglist(const QMailMessageIdList &ids) {
56 QList<quint64> list;
57 foreach(const QMailMessageId &id, ids) {
58 list << id.toULongLong();
59 }
60 return list;
61 }
62
63 inline QMailFolderKey to_folder_key(const QByteArray &key) {
64 QMailFolderKey mKey;
65 QByteArray m = key;
66 QDataStream keystream(&m, QIODevice::ReadWrite);
67 mKey.deserialize(keystream);
68 return mKey;
69 }
70
71 inline QByteArray folder_key_bytes(const QMailFolderKey &key) {
72 QByteArray msgKey;
73 QDataStream keystream(&msgKey, QIODevice::WriteOnly);
74 key.serialize(keystream);
75 return msgKey;
76 }
77
78 inline QMailFolderSortKey to_folder_sort_key(const QByteArray &key) {
79 QMailFolderSortKey sKey;
80 QByteArray s = key;
81 QDataStream skeystream(&s, QIODevice::ReadWrite);
82 sKey.deserialize(skeystream);
83 return sKey;
84 }
85
86 inline QByteArray folder_sort_key_bytes(const QMailFolderSortKey &key) {
87 QByteArray sortKey;
88 QDataStream keystream(&sortKey, QIODevice::WriteOnly);
89 key.serialize(keystream);
90 return sortKey;
91 }
92
93 inline QMailFolderIdList from_dbus_folderlist(const QList<quint64> &ids) {
94 QMailFolderIdList list;
95 foreach(const quint64 &id, ids) {
96 QMailFolderId folderId(id);
97 list << folderId;
98 }
99 return list;
100 }
101
102 inline QList<quint64> to_dbus_folderlist(const QMailFolderIdList &ids) {
103 QList<quint64> list;
104 foreach(const QMailFolderId &id, ids) {
105 list << id.toULongLong();
106 }
107 return list;
108 }
109
110 inline QMailAccountKey to_account_key(const QByteArray &key) {
111 QMailAccountKey mKey;
112 QByteArray m = key;
113 QDataStream keystream(&m, QIODevice::ReadWrite);
114 mKey.deserialize(keystream);
115 return mKey;
116 }
117
118 inline QByteArray account_key_bytes(const QMailAccountKey &key) {
119 QByteArray accountKey;
120 QDataStream keystream(&accountKey, QIODevice::WriteOnly);
121 key.serialize(keystream);
122 return accountKey;
123 }
124
125 inline QMailAccountSortKey to_account_sort_key(const QByteArray &key) {
126 QMailAccountSortKey sKey;
127 QByteArray s = key;
128 QDataStream skeystream(&s, QIODevice::ReadWrite);
129 sKey.deserialize(skeystream);
130 return sKey;
131 }
132
133 inline QByteArray account_sort_key_bytes(const QMailAccountSortKey &key) {
134 QByteArray sortKey;
135 QDataStream keystream(&sortKey, QIODevice::WriteOnly);
136 key.serialize(keystream);
137 return sortKey;
138 }
139
140 inline QMailAccountIdList from_dbus_accountlist(const QList<quint64> &ids) {
141 QMailAccountIdList list;
142 foreach(const quint64 &id, ids) {
143 QMailAccountId aId(id);
144 list << aId;
145 }
146 return list;
147 }
148
149 inline QList<quint64> to_dbus_accountlist(const QMailAccountIdList &ids) {
150 QList<quint64> list;
151 foreach(const QMailAccountId &id, ids) {
152 list << id.toULongLong();
153 }
154 return list;
155 }
156
157
158
159 #endif // SERVICEUTILS_H