Tue, 26 Feb 2013 21:20:25 -0500
silc: Use appropriate datatype for SilcMessageFlags
| 8849 | 1 | /* |
| 2 | ||
| 15884 | 3 | silcpurple_util.c |
| 8849 | 4 | |
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
7 | Copyright (C) 2004 - 2007 Pekka Riikonen |
| 8849 | 8 | |
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
20 | #include "internal.h" |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
21 | #include "silc.h" |
| 8849 | 22 | #include "silcclient.h" |
| 15884 | 23 | #include "silcpurple.h" |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
24 | #include "imgstore.h" |
| 8849 | 25 | |
| 26 | /**************************** Utility Routines *******************************/ | |
| 27 | ||
| 28 | static char str[256], str2[256]; | |
| 29 | ||
| 15884 | 30 | const char *silcpurple_silcdir(void) |
| 8849 | 31 | { |
| 15884 | 32 | const char *hd = purple_home_dir(); |
| 8849 | 33 | memset(str, 0, sizeof(str)); |
| 34 | g_snprintf(str, sizeof(str) - 1, "%s" G_DIR_SEPARATOR_S ".silc", hd ? hd : "/tmp"); | |
| 35 | return (const char *)str; | |
| 36 | } | |
| 37 | ||
| 15884 | 38 | const char *silcpurple_session_file(const char *account) |
| 8849 | 39 | { |
| 40 | memset(str2, 0, sizeof(str2)); | |
| 41 | g_snprintf(str2, sizeof(str2) - 1, "%s" G_DIR_SEPARATOR_S "%s_session", | |
| 15884 | 42 | silcpurple_silcdir(), account); |
| 8849 | 43 | return (const char *)str2; |
| 44 | } | |
| 45 | ||
| 15884 | 46 | gboolean silcpurple_ip_is_private(const char *ip) |
| 8849 | 47 | { |
| 48 | if (silc_net_is_ip4(ip)) { | |
| 49 | if (!strncmp(ip, "10.", 3)) { | |
| 50 | return TRUE; | |
| 51 | } else if (!strncmp(ip, "172.", 4) && strlen(ip) > 6) { | |
| 52 | char tmp[3]; | |
| 8910 | 53 | int s; |
| 8849 | 54 | memset(tmp, 0, sizeof(tmp)); |
| 55 | strncpy(tmp, ip + 4, 2); | |
| 8910 | 56 | s = atoi(tmp); |
| 8849 | 57 | if (s >= 16 && s <= 31) |
| 58 | return TRUE; | |
| 59 | } else if (!strncmp(ip, "192.168.", 8)) { | |
| 60 | return TRUE; | |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | return FALSE; | |
| 65 | } | |
| 66 | ||
| 67 | /* This checks stats for various SILC files and directories. First it | |
| 68 | checks if ~/.silc directory exist and is owned by the correct user. If | |
| 69 | it doesn't exist, it will create the directory. After that it checks if | |
| 70 | user's Public and Private key files exists and creates them if needed. */ | |
| 71 | ||
| 15884 | 72 | gboolean silcpurple_check_silc_dir(PurpleConnection *gc) |
| 8849 | 73 | { |
| 74 | char filename[256], file_public_key[256], file_private_key[256]; | |
| 75 | char servfilename[256], clientfilename[256], friendsfilename[256]; | |
|
10825
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
76 | char pkd[256], prd[256]; |
| 8849 | 77 | struct stat st; |
| 78 | struct passwd *pw; | |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
79 | int fd; |
| 8849 | 80 | |
| 81 | pw = getpwuid(getuid()); | |
| 82 | if (!pw) { | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
83 | purple_debug_error("silc", "silc: %s\n", g_strerror(errno)); |
| 8849 | 84 | return FALSE; |
| 85 | } | |
| 86 | ||
| 15884 | 87 | g_snprintf(filename, sizeof(filename) - 1, "%s", silcpurple_silcdir()); |
| 8849 | 88 | g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys", |
| 15884 | 89 | silcpurple_silcdir()); |
| 8849 | 90 | g_snprintf(clientfilename, sizeof(clientfilename) - 1, "%s" G_DIR_SEPARATOR_S "clientkeys", |
| 15884 | 91 | silcpurple_silcdir()); |
| 8849 | 92 | g_snprintf(friendsfilename, sizeof(friendsfilename) - 1, "%s" G_DIR_SEPARATOR_S "friends", |
| 15884 | 93 | silcpurple_silcdir()); |
| 8849 | 94 | |
| 95 | /* | |
| 96 | * Check ~/.silc directory | |
| 97 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
98 | if ((g_stat(filename, &st)) == -1) { |
| 8849 | 99 | /* If dir doesn't exist */ |
| 100 | if (errno == ENOENT) { | |
| 101 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
102 | if ((g_mkdir(filename, 0755)) == -1) { |
| 15884 | 103 | purple_debug_error("silc", "Couldn't create '%s' directory\n", filename); |
| 8849 | 104 | return FALSE; |
| 105 | } | |
| 106 | } else { | |
| 15884 | 107 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 108 | filename); |
| 109 | return FALSE; | |
| 110 | } | |
| 111 | } else { | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
112 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, g_strerror(errno)); |
| 8849 | 113 | return FALSE; |
| 114 | } | |
| 115 | } else { | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
116 | #ifndef _WIN32 |
| 8849 | 117 | /* Check the owner of the dir */ |
| 118 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { | |
| 15884 | 119 | purple_debug_error("silc", "You don't seem to own '%s' directory\n", |
| 8849 | 120 | filename); |
| 121 | return FALSE; | |
| 122 | } | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
123 | #endif |
| 8849 | 124 | } |
| 125 | ||
| 126 | /* | |
| 127 | * Check ~./silc/serverkeys directory | |
| 128 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
129 | if ((g_stat(servfilename, &st)) == -1) { |
| 8849 | 130 | /* If dir doesn't exist */ |
| 131 | if (errno == ENOENT) { | |
| 132 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
133 | if ((g_mkdir(servfilename, 0755)) == -1) { |
| 15884 | 134 | purple_debug_error("silc", "Couldn't create '%s' directory\n", servfilename); |
| 8849 | 135 | return FALSE; |
| 136 | } | |
| 137 | } else { | |
| 15884 | 138 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 139 | servfilename); |
| 140 | return FALSE; | |
| 141 | } | |
| 142 | } else { | |
| 15884 | 143 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
144 | servfilename, g_strerror(errno)); |
| 8849 | 145 | return FALSE; |
| 146 | } | |
| 147 | } | |
| 148 | ||
| 149 | /* | |
| 150 | * Check ~./silc/clientkeys directory | |
| 151 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
152 | if ((g_stat(clientfilename, &st)) == -1) { |
| 8849 | 153 | /* If dir doesn't exist */ |
| 154 | if (errno == ENOENT) { | |
| 155 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
156 | if ((g_mkdir(clientfilename, 0755)) == -1) { |
| 15884 | 157 | purple_debug_error("silc", "Couldn't create '%s' directory\n", clientfilename); |
| 8849 | 158 | return FALSE; |
| 159 | } | |
| 160 | } else { | |
| 15884 | 161 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 162 | clientfilename); |
| 163 | return FALSE; | |
| 164 | } | |
| 165 | } else { | |
| 15884 | 166 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
167 | clientfilename, g_strerror(errno)); |
| 8849 | 168 | return FALSE; |
| 169 | } | |
| 170 | } | |
| 171 | ||
| 172 | /* | |
| 173 | * Check ~./silc/friends directory | |
| 174 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
175 | if ((g_stat(friendsfilename, &st)) == -1) { |
| 8849 | 176 | /* If dir doesn't exist */ |
| 177 | if (errno == ENOENT) { | |
| 178 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
179 | if ((g_mkdir(friendsfilename, 0755)) == -1) { |
| 15884 | 180 | purple_debug_error("silc", "Couldn't create '%s' directory\n", friendsfilename); |
| 8849 | 181 | return FALSE; |
| 182 | } | |
| 183 | } else { | |
| 15884 | 184 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 185 | friendsfilename); |
| 186 | return FALSE; | |
| 187 | } | |
| 188 | } else { | |
| 15884 | 189 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
190 | friendsfilename, g_strerror(errno)); |
| 8849 | 191 | return FALSE; |
| 192 | } | |
| 193 | } | |
| 194 | ||
| 195 | /* | |
| 196 | * Check Public and Private keys | |
| 197 | */ | |
| 15884 | 198 | g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); |
| 199 | g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); | |
| 8849 | 200 | g_snprintf(file_public_key, sizeof(file_public_key) - 1, "%s", |
| 15884 | 201 | purple_account_get_string(gc->account, "public-key", pkd)); |
| 8849 | 202 | g_snprintf(file_private_key, sizeof(file_public_key) - 1, "%s", |
| 15884 | 203 | purple_account_get_string(gc->account, "private-key", prd)); |
| 8849 | 204 | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
205 | if ((g_stat(file_public_key, &st)) == -1) { |
| 8849 | 206 | /* If file doesn't exist */ |
| 207 | if (errno == ENOENT) { | |
| 15884 | 208 | purple_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); |
| 209 | if (!silc_create_key_pair(SILCPURPLE_DEF_PKCS, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
210 | SILCPURPLE_DEF_PKCS_LEN, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
211 | file_public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
212 | file_private_key, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
213 | (gc->password == NULL) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
214 | ? "" : gc->password, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
215 | NULL, NULL, FALSE)) { |
| 21279 | 216 | purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
23325
diff
changeset
|
217 | _("Unable to create SILC key pair")); |
|
14148
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
218 | return FALSE; |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
219 | } |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
220 | |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
221 | if ((g_stat(file_public_key, &st)) == -1) { |
| 15884 | 222 | purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
223 | file_public_key, g_strerror(errno)); |
|
14148
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
224 | return FALSE; |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
225 | } |
| 8849 | 226 | } else { |
| 15884 | 227 | purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
228 | file_public_key, g_strerror(errno)); |
| 8849 | 229 | return FALSE; |
| 230 | } | |
| 231 | } | |
| 232 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
233 | #ifndef _WIN32 |
| 8849 | 234 | /* Check the owner of the public key */ |
| 235 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { | |
| 15884 | 236 | purple_debug_error("silc", "You don't seem to own your public key!?\n"); |
| 8849 | 237 | return FALSE; |
| 238 | } | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
239 | #endif |
| 8849 | 240 | |
|
14227
e760c7dd2e7a
[gaim-migrate @ 16815]
Daniel Atallah <datallah@pidgin.im>
parents:
14218
diff
changeset
|
241 | if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) { |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
242 | if ((fstat(fd, &st)) == -1) { |
| 15884 | 243 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
244 | file_private_key, g_strerror(errno)); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
245 | close(fd); |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
246 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
247 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
248 | } else if ((g_stat(file_private_key, &st)) == -1) { |
| 8849 | 249 | /* If file doesn't exist */ |
| 250 | if (errno == ENOENT) { | |
| 15884 | 251 | purple_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); |
| 252 | if (!silc_create_key_pair(SILCPURPLE_DEF_PKCS, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
253 | SILCPURPLE_DEF_PKCS_LEN, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
254 | file_public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
255 | file_private_key, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
256 | (gc->password == NULL) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
257 | ? "" : gc->password, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
258 | NULL, NULL, FALSE)) { |
| 21279 | 259 | purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
23325
diff
changeset
|
260 | _("Unable to create SILC key pair")); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
261 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
262 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
263 | |
|
14227
e760c7dd2e7a
[gaim-migrate @ 16815]
Daniel Atallah <datallah@pidgin.im>
parents:
14218
diff
changeset
|
264 | if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) { |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
265 | if ((fstat(fd, &st)) == -1) { |
| 15884 | 266 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
267 | file_private_key, g_strerror(errno)); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
268 | close(fd); |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
269 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
270 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
271 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
272 | /* This shouldn't really happen because silc_create_key_pair() |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
273 | * will set the permissions */ |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
274 | else if ((g_stat(file_private_key, &st)) == -1) { |
| 15884 | 275 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
276 | file_private_key, g_strerror(errno)); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
277 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
278 | } |
| 8849 | 279 | } else { |
| 15884 | 280 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20289
diff
changeset
|
281 | file_private_key, g_strerror(errno)); |
| 8849 | 282 | return FALSE; |
| 283 | } | |
| 284 | } | |
| 285 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
286 | #ifndef _WIN32 |
| 8849 | 287 | /* Check the owner of the private key */ |
| 288 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { | |
| 15884 | 289 | purple_debug_error("silc", "You don't seem to own your private key!?\n"); |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
290 | if (fd != -1) |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
291 | close(fd); |
| 8849 | 292 | return FALSE; |
| 293 | } | |
| 294 | ||
| 295 | /* Check the permissions for the private key */ | |
| 296 | if ((st.st_mode & 0777) != 0600) { | |
| 15884 | 297 | purple_debug_warning("silc", "Wrong permissions in your private key file `%s'!\n" |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
298 | "Trying to change them ...\n", file_private_key); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
299 | if ((fd == -1) || (fchmod(fd, S_IRUSR | S_IWUSR)) == -1) { |
| 15884 | 300 | purple_debug_error("silc", |
| 8849 | 301 | "Failed to change permissions for private key file!\n" |
| 302 | "Permissions for your private key file must be 0600.\n"); | |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
303 | if (fd != -1) |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
304 | close(fd); |
| 8849 | 305 | return FALSE; |
| 306 | } | |
| 15884 | 307 | purple_debug_warning("silc", "Done.\n\n"); |
| 8849 | 308 | } |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
309 | #endif |
| 8849 | 310 | |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
311 | if (fd != -1) |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
312 | close(fd); |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
313 | |
| 8849 | 314 | return TRUE; |
| 315 | } | |
| 316 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
317 | #ifdef _WIN32 |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
318 | struct passwd *getpwuid(uid_t uid) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
319 | struct passwd *pwd = calloc(1, sizeof(struct passwd)); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
320 | return pwd; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
321 | } |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
322 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
323 | uid_t getuid() { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
324 | return 0; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
325 | } |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
326 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
327 | uid_t geteuid() { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
328 | return 0; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
329 | } |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
330 | #endif |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
331 | |
| 15884 | 332 | void silcpurple_show_public_key(SilcPurple sg, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
333 | const char *name, SilcPublicKey public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
334 | GCallback callback, void *context) |
| 8849 | 335 | { |
| 336 | SilcPublicKeyIdentifier ident; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
337 | SilcSILCPublicKey silc_pubkey; |
| 8849 | 338 | char *fingerprint, *babbleprint; |
| 339 | unsigned char *pk; | |
| 340 | SilcUInt32 pk_len, key_len = 0; | |
| 341 | GString *s; | |
| 342 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
343 | /* We support showing only SILC public keys for now */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
344 | if (silc_pkcs_get_type(public_key) != SILC_PKCS_SILC) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
345 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
346 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
347 | silc_pubkey = silc_pkcs_get_context(SILC_PKCS_SILC, public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
348 | ident = &silc_pubkey->identifier; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
349 | key_len = silc_pkcs_public_key_get_len(public_key); |
| 8849 | 350 | |
| 351 | pk = silc_pkcs_public_key_encode(public_key, &pk_len); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
352 | if (!pk) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
353 | return; |
| 8849 | 354 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); |
| 355 | babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
356 | if (!fingerprint || !babbleprint) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
357 | return; |
| 8849 | 358 | |
| 359 | s = g_string_new(""); | |
| 360 | if (ident->realname) | |
|
10825
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
361 | /* Hint for translators: Please check the tabulator width here and in |
|
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
362 | the next strings (short strings: 2 tabs, longer strings 1 tab, |
| 9274 | 363 | sum: 3 tabs or 24 characters) */ |
| 364 | g_string_append_printf(s, _("Real Name: \t%s\n"), ident->realname); | |
| 8849 | 365 | if (ident->username) |
| 9274 | 366 | g_string_append_printf(s, _("User Name: \t%s\n"), ident->username); |
| 8849 | 367 | if (ident->email) |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
22972
diff
changeset
|
368 | g_string_append_printf(s, _("Email: \t\t%s\n"), ident->email); |
| 8849 | 369 | if (ident->host) |
| 9274 | 370 | g_string_append_printf(s, _("Host Name: \t%s\n"), ident->host); |
| 8849 | 371 | if (ident->org) |
| 9274 | 372 | g_string_append_printf(s, _("Organization: \t%s\n"), ident->org); |
| 8849 | 373 | if (ident->country) |
| 9274 | 374 | g_string_append_printf(s, _("Country: \t%s\n"), ident->country); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
375 | g_string_append_printf(s, _("Algorithm: \t%s\n"), silc_pubkey->pkcs->name); |
| 9274 | 376 | g_string_append_printf(s, _("Key Length: \t%d bits\n"), (int)key_len); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
377 | if (ident->version) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
378 | g_string_append_printf(s, _("Version: \t%s\n"), ident->version); |
| 9274 | 379 | g_string_append_printf(s, "\n"); |
| 380 | g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint); | |
| 381 | g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint); | |
| 8849 | 382 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
383 | purple_request_action(sg->gc, _("Public Key Information"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
384 | _("Public Key Information"), |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
385 | s->str, 0, purple_connection_get_account(sg->gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
386 | NULL, NULL, context, 1, _("Close"), callback); |
| 8849 | 387 | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
388 | g_string_free(s, TRUE); |
| 8849 | 389 | silc_free(fingerprint); |
| 390 | silc_free(babbleprint); | |
| 391 | silc_free(pk); | |
| 392 | } | |
| 393 | ||
| 394 | SilcAttributePayload | |
| 15884 | 395 | silcpurple_get_attr(SilcDList attrs, SilcAttribute attribute) |
| 8849 | 396 | { |
| 397 | SilcAttributePayload attr = NULL; | |
| 398 | ||
| 399 | if (!attrs) | |
| 400 | return NULL; | |
| 401 | ||
| 402 | silc_dlist_start(attrs); | |
| 403 | while ((attr = silc_dlist_get(attrs)) != SILC_LIST_END) | |
| 404 | if (attribute == silc_attribute_get_attribute(attr)) | |
| 405 | break; | |
| 406 | ||
| 407 | return attr; | |
| 408 | } | |
| 409 | ||
| 15884 | 410 | void silcpurple_get_umode_string(SilcUInt32 mode, char *buf, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
411 | SilcUInt32 buf_size) |
| 8849 | 412 | { |
| 413 | memset(buf, 0, buf_size); | |
| 414 | if ((mode & SILC_UMODE_SERVER_OPERATOR) || | |
| 415 | (mode & SILC_UMODE_ROUTER_OPERATOR)) { | |
| 416 | strcat(buf, (mode & SILC_UMODE_SERVER_OPERATOR) ? | |
| 417 | "[server operator] " : | |
| 418 | (mode & SILC_UMODE_ROUTER_OPERATOR) ? | |
| 419 | "[SILC operator] " : "[unknown mode] "); | |
| 420 | } | |
| 421 | if (mode & SILC_UMODE_GONE) | |
| 422 | strcat(buf, "[away] "); | |
| 423 | if (mode & SILC_UMODE_INDISPOSED) | |
| 424 | strcat(buf, "[indisposed] "); | |
| 425 | if (mode & SILC_UMODE_BUSY) | |
| 426 | strcat(buf, "[busy] "); | |
| 427 | if (mode & SILC_UMODE_PAGE) | |
| 428 | strcat(buf, "[wake me up] "); | |
| 429 | if (mode & SILC_UMODE_HYPER) | |
| 430 | strcat(buf, "[hyperactive] "); | |
| 431 | if (mode & SILC_UMODE_ROBOT) | |
| 432 | strcat(buf, "[robot] "); | |
| 433 | if (mode & SILC_UMODE_ANONYMOUS) | |
| 434 | strcat(buf, "[anonymous] "); | |
| 435 | if (mode & SILC_UMODE_BLOCK_PRIVMSG) | |
| 436 | strcat(buf, "[blocks private messages] "); | |
| 437 | if (mode & SILC_UMODE_DETACHED) | |
| 438 | strcat(buf, "[detached] "); | |
| 439 | if (mode & SILC_UMODE_REJECT_WATCHING) | |
| 440 | strcat(buf, "[rejects watching] "); | |
| 441 | if (mode & SILC_UMODE_BLOCK_INVITE) | |
| 442 | strcat(buf, "[blocks invites] "); | |
|
22470
6fb4ab976585
chomp chomp chomp chomp chomp chomp chomp chomp chomp chomp
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
443 | g_strchomp(buf); |
| 8849 | 444 | } |
| 445 | ||
| 15884 | 446 | void silcpurple_get_chmode_string(SilcUInt32 mode, char *buf, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
447 | SilcUInt32 buf_size) |
| 8849 | 448 | { |
| 449 | memset(buf, 0, buf_size); | |
| 450 | if (mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) | |
| 451 | strcat(buf, "[permanent] "); | |
| 452 | if (mode & SILC_CHANNEL_MODE_PRIVATE) | |
| 453 | strcat(buf, "[private] "); | |
| 454 | if (mode & SILC_CHANNEL_MODE_SECRET) | |
| 455 | strcat(buf, "[secret] "); | |
| 456 | if (mode & SILC_CHANNEL_MODE_PRIVKEY) | |
| 457 | strcat(buf, "[private key] "); | |
| 458 | if (mode & SILC_CHANNEL_MODE_INVITE) | |
| 459 | strcat(buf, "[invite only] "); | |
| 460 | if (mode & SILC_CHANNEL_MODE_TOPIC) | |
| 461 | strcat(buf, "[topic restricted] "); | |
| 462 | if (mode & SILC_CHANNEL_MODE_ULIMIT) | |
| 463 | strcat(buf, "[user count limit] "); | |
| 464 | if (mode & SILC_CHANNEL_MODE_PASSPHRASE) | |
| 465 | strcat(buf, "[passphrase auth] "); | |
| 466 | if (mode & SILC_CHANNEL_MODE_CHANNEL_AUTH) | |
| 467 | strcat(buf, "[public key auth] "); | |
| 468 | if (mode & SILC_CHANNEL_MODE_SILENCE_USERS) | |
| 469 | strcat(buf, "[users silenced] "); | |
| 470 | if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS) | |
| 471 | strcat(buf, "[operators silenced] "); | |
|
22470
6fb4ab976585
chomp chomp chomp chomp chomp chomp chomp chomp chomp chomp
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
472 | g_strchomp(buf); |
| 8849 | 473 | } |
| 474 | ||
| 15884 | 475 | void silcpurple_get_chumode_string(SilcUInt32 mode, char *buf, |
| 8849 | 476 | SilcUInt32 buf_size) |
| 477 | { | |
| 478 | memset(buf, 0, buf_size); | |
| 479 | if (mode & SILC_CHANNEL_UMODE_CHANFO) | |
| 480 | strcat(buf, "[founder] "); | |
| 481 | if (mode & SILC_CHANNEL_UMODE_CHANOP) | |
| 482 | strcat(buf, "[operator] "); | |
| 483 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES) | |
| 484 | strcat(buf, "[blocks messages] "); | |
| 485 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_USERS) | |
| 486 | strcat(buf, "[blocks user messages] "); | |
| 487 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_ROBOTS) | |
| 488 | strcat(buf, "[blocks robot messages] "); | |
| 489 | if (mode & SILC_CHANNEL_UMODE_QUIET) | |
| 490 | strcat(buf, "[quieted] "); | |
|
22470
6fb4ab976585
chomp chomp chomp chomp chomp chomp chomp chomp chomp chomp
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
491 | g_strchomp(buf); |
| 8849 | 492 | } |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
493 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
494 | void |
| 15884 | 495 | silcpurple_parse_attrs(SilcDList attrs, char **moodstr, char **statusstr, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
496 | char **contactstr, char **langstr, char **devicestr, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
497 | char **tzstr, char **geostr) |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
498 | { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
499 | SilcAttributePayload attr; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
500 | SilcAttributeMood mood = 0; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
501 | SilcAttributeContact contact; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
502 | SilcAttributeObjDevice device; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
503 | SilcAttributeObjGeo geo; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
504 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
505 | char tmp[1024]; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
506 | GString *s; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
507 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
508 | *moodstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
509 | *statusstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
510 | *contactstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
511 | *langstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
512 | *devicestr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
513 | *tzstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
514 | *geostr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
515 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
516 | if (!attrs) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
517 | return; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
518 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
519 | s = g_string_new(""); |
| 15884 | 520 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_MOOD); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
521 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
522 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
523 | g_string_append_printf(s, "[%s] ", _("Happy")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
524 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
525 | g_string_append_printf(s, "[%s] ", _("Sad")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
526 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
527 | g_string_append_printf(s, "[%s] ", _("Angry")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
528 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
529 | g_string_append_printf(s, "[%s] ", _("Jealous")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
530 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
531 | g_string_append_printf(s, "[%s] ", _("Ashamed")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
532 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
533 | g_string_append_printf(s, "[%s] ", _("Invincible")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
534 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
535 | g_string_append_printf(s, "[%s] ", _("In Love")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
536 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
537 | g_string_append_printf(s, "[%s] ", _("Sleepy")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
538 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
539 | g_string_append_printf(s, "[%s] ", _("Bored")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
540 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
541 | g_string_append_printf(s, "[%s] ", _("Excited")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
542 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
543 | g_string_append_printf(s, "[%s] ", _("Anxious")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
544 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
545 | if (strlen(s->str)) { |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
546 | *moodstr = g_string_free(s, FALSE); |
|
22470
6fb4ab976585
chomp chomp chomp chomp chomp chomp chomp chomp chomp chomp
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
547 | g_strchomp(*moodstr); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
548 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
549 | g_string_free(s, TRUE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
550 | |
| 15884 | 551 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
552 | memset(tmp, 0, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
553 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
554 | *statusstr = g_strdup(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
555 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
556 | s = g_string_new(""); |
| 15884 | 557 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_CONTACT); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
558 | if (attr && silc_attribute_get_object(attr, &contact, sizeof(contact))) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
559 | if (contact & SILC_ATTRIBUTE_CONTACT_CHAT) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
560 | g_string_append_printf(s, "[%s] ", _("Chat")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
561 | if (contact & SILC_ATTRIBUTE_CONTACT_EMAIL) |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
22972
diff
changeset
|
562 | g_string_append_printf(s, "[%s] ", _("Email")); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
563 | if (contact & SILC_ATTRIBUTE_CONTACT_CALL) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
564 | g_string_append_printf(s, "[%s] ", _("Phone")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
565 | if (contact & SILC_ATTRIBUTE_CONTACT_PAGE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
566 | g_string_append_printf(s, "[%s] ", _("Paging")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
567 | if (contact & SILC_ATTRIBUTE_CONTACT_SMS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
568 | g_string_append_printf(s, "[%s] ", _("SMS")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
569 | if (contact & SILC_ATTRIBUTE_CONTACT_MMS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
570 | g_string_append_printf(s, "[%s] ", _("MMS")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
571 | if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
572 | g_string_append_printf(s, "[%s] ", _("Video Conferencing")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
573 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
574 | if (strlen(s->str)) { |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
575 | *contactstr = g_string_free(s, FALSE); |
|
22470
6fb4ab976585
chomp chomp chomp chomp chomp chomp chomp chomp chomp chomp
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
576 | g_strchomp(*contactstr); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
577 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
578 | g_string_free(s, TRUE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
579 | |
| 15884 | 580 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
581 | memset(tmp, 0, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
582 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
583 | *langstr = g_strdup(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
584 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
585 | s = g_string_new(""); |
| 15884 | 586 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_DEVICE_INFO); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
587 | memset(&device, 0, sizeof(device)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
588 | if (attr && silc_attribute_get_object(attr, &device, sizeof(device))) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
589 | if (device.type == SILC_ATTRIBUTE_DEVICE_COMPUTER) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
590 | g_string_append_printf(s, "%s: ", _("Computer")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
591 | if (device.type == SILC_ATTRIBUTE_DEVICE_MOBILE_PHONE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
592 | g_string_append_printf(s, "%s: ", _("Mobile Phone")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
593 | if (device.type == SILC_ATTRIBUTE_DEVICE_PDA) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
594 | g_string_append_printf(s, "%s: ", _("PDA")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
595 | if (device.type == SILC_ATTRIBUTE_DEVICE_TERMINAL) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
596 | g_string_append_printf(s, "%s: ", _("Terminal")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
597 | g_string_append_printf(s, "%s %s %s %s", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
598 | device.manufacturer ? device.manufacturer : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
599 | device.version ? device.version : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
600 | device.model ? device.model : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
601 | device.language ? device.language : ""); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
602 | } |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
603 | if (strlen(s->str)) |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
604 | *devicestr = g_string_free(s, FALSE); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
605 | else |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
606 | g_string_free(s, TRUE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
607 | |
| 15884 | 608 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
609 | memset(tmp, 0, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
610 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
611 | *tzstr = g_strdup(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
612 | |
| 15884 | 613 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_GEOLOCATION); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
614 | memset(&geo, 0, sizeof(geo)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
615 | if (attr && silc_attribute_get_object(attr, &geo, sizeof(geo))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
616 | *geostr = g_strdup_printf("%s %s %s (%s)", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
617 | geo.longitude ? geo.longitude : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
618 | geo.latitude ? geo.latitude : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
619 | geo.altitude ? geo.altitude : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
620 | geo.accuracy ? geo.accuracy : ""); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
621 | } |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
622 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
623 | /* Returns MIME type of filetype */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
624 | |
| 15884 | 625 | char *silcpurple_file2mime(const char *filename) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
626 | { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
627 | const char *ct; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
628 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
629 | ct = strrchr(filename, '.'); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
630 | if (!ct) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
631 | return NULL; |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
632 | else if (!g_ascii_strcasecmp(".png", ct)) |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
633 | return g_strdup("image/png"); |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
634 | else if (!g_ascii_strcasecmp(".jpg", ct)) |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
635 | return g_strdup("image/jpeg"); |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
636 | else if (!g_ascii_strcasecmp(".jpeg", ct)) |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
637 | return g_strdup("image/jpeg"); |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
638 | else if (!g_ascii_strcasecmp(".gif", ct)) |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
639 | return g_strdup("image/gif"); |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
640 | else if (!g_ascii_strcasecmp(".tiff", ct)) |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
641 | return g_strdup("image/tiff"); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
642 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
643 | return NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
644 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
645 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
646 | /* Checks if message has images, and assembles MIME message if it has. |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
647 | If only one image is present, creates simple MIME image message. If |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
648 | there are multiple images and/or text with images multipart MIME |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
649 | message is created. */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
650 | |
|
33798
ab26d8e3da97
silc: Use appropriate datatype for SilcMessageFlags
Daniel Atallah <datallah@pidgin.im>
parents:
28981
diff
changeset
|
651 | SilcDList silcpurple_image_message(const char *msg, SilcMessageFlags *mflags) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
652 | { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
653 | SilcMime mime = NULL, p; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
654 | SilcDList list, parts = NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
655 | const char *start, *end, *last; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
656 | GData *attribs; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
657 | char *type; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
658 | gboolean images = FALSE; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
659 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
660 | last = msg; |
| 15884 | 661 | while (last && *last && purple_markup_find_tag("img", last, &start, |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
662 | &end, &attribs)) { |
| 15884 | 663 | PurpleStoredImage *image = NULL; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
664 | const char *id; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
665 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
666 | /* Check if there is text before image */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
667 | if (start - last) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
668 | char *text, *tmp; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
669 | p = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
670 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
671 | /* Add content type */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
672 | silc_mime_add_field(p, "Content-Type", |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
673 | "text/plain; charset=utf-8"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
674 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
675 | tmp = g_strndup(last, start - last); |
| 15884 | 676 | text = purple_unescape_html(tmp); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
677 | g_free(tmp); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
678 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
679 | /* Add text */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
680 | silc_mime_add_data(p, (const unsigned char *)text, strlen(text)); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
681 | g_free(text); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
682 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
683 | if (!parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
684 | parts = silc_dlist_init(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
685 | silc_dlist_add(parts, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
686 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
687 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
688 | id = g_datalist_get_data(&attribs, "id"); |
|
16560
6d1c2bb6ee4c
Finally fix SILC fully, now that i have HAVE_SILCMIME_H defined.
Daniel Atallah <datallah@pidgin.im>
parents:
16492
diff
changeset
|
689 | if (id && (image = purple_imgstore_find_by_id(atoi(id)))) { |
| 15884 | 690 | unsigned long imglen = purple_imgstore_get_size(image); |
|
16560
6d1c2bb6ee4c
Finally fix SILC fully, now that i have HAVE_SILCMIME_H defined.
Daniel Atallah <datallah@pidgin.im>
parents:
16492
diff
changeset
|
691 | gconstpointer img = purple_imgstore_get_data(image); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
692 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
693 | p = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
694 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
695 | /* Add content type */ |
| 15884 | 696 | type = silcpurple_file2mime(purple_imgstore_get_filename(image)); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
697 | if (!type) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
698 | g_datalist_clear(&attribs); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
699 | last = end + 1; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
700 | continue; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
701 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
702 | silc_mime_add_field(p, "Content-Type", type); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22470
diff
changeset
|
703 | g_free(type); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
704 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
705 | /* Add content transfer encoding */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
706 | silc_mime_add_field(p, "Content-Transfer-Encoding", "binary"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
707 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
708 | /* Add image data */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
709 | silc_mime_add_data(p, img, imglen); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
710 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
711 | if (!parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
712 | parts = silc_dlist_init(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
713 | silc_dlist_add(parts, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
714 | images = TRUE; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
715 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
716 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
717 | g_datalist_clear(&attribs); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
718 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
719 | /* Continue after tag */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
720 | last = end + 1; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
721 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
722 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
723 | /* Check for text after the image(s) */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
724 | if (images && last && *last) { |
| 15884 | 725 | char *tmp = purple_unescape_html(last); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
726 | p = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
727 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
728 | /* Add content type */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
729 | silc_mime_add_field(p, "Content-Type", |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
730 | "text/plain; charset=utf-8"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
731 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
732 | /* Add text */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
733 | silc_mime_add_data(p, (const unsigned char *)tmp, strlen(tmp)); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
734 | g_free(tmp); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
735 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
736 | if (!parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
737 | parts = silc_dlist_init(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
738 | silc_dlist_add(parts, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
739 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
740 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
741 | /* If there weren't any images, don't return anything. */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
742 | if (!images) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
743 | if (parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
744 | silc_dlist_uninit(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
745 | return NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
746 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
747 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
748 | if (silc_dlist_count(parts) > 1) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
749 | /* Multipart MIME message */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
750 | char b[32]; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
751 | mime = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
752 | silc_mime_add_field(mime, "MIME-Version", "1.0"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
753 | g_snprintf(b, sizeof(b), "b%4X%4X", |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
754 | (unsigned int)time(NULL), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
755 | silc_dlist_count(parts)); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
756 | silc_mime_set_multipart(mime, "mixed", b); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
757 | silc_dlist_start(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
758 | while ((p = silc_dlist_get(parts)) != SILC_LIST_END) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
759 | silc_mime_add_multipart(mime, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
760 | } else { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
761 | /* Simple MIME message */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
762 | silc_dlist_start(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
763 | mime = silc_dlist_get(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
764 | silc_mime_add_field(mime, "MIME-Version", "1.0"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
765 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
766 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
767 | *mflags &= ~SILC_MESSAGE_FLAG_UTF8; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
768 | *mflags |= SILC_MESSAGE_FLAG_DATA; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
769 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
770 | /* Encode message. Fragment if it is too large */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
771 | list = silc_mime_encode_partial(mime, 0xfc00); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
772 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
773 | silc_dlist_uninit(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
774 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
775 | /* Added multiparts gets freed here */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
776 | silc_mime_free(mime); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
777 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
778 | return list; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
779 | } |