Sat, 03 Nov 2007 17:52:28 +0000
replace most calls to strerror with calls to g_strerror. strerror will return
a locale-specific string in the locale-specific encoding, which isn't
guaranteed to be UTF-8. g_strerror will always return a UTF-8 string.
I left gg and zephyr untouched, since gg doesn't include glib headers yet,
and zephyr does something weird with a #define for strerror. Someone more
familliar with those should take a look.
And the win32 guys should check and see if I screwed something up, since
they had strerror #defined to something else.
This should fix #2247 (and maybe some mystery crashes)
| 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 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
20 | #include "silc.h" |
| 8849 | 21 | #include "silcclient.h" |
| 15884 | 22 | #include "silcpurple.h" |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
23 | #include "imgstore.h" |
| 8849 | 24 | |
| 25 | /**************************** Utility Routines *******************************/ | |
| 26 | ||
| 27 | static char str[256], str2[256]; | |
| 28 | ||
| 15884 | 29 | const char *silcpurple_silcdir(void) |
| 8849 | 30 | { |
| 15884 | 31 | const char *hd = purple_home_dir(); |
| 8849 | 32 | memset(str, 0, sizeof(str)); |
| 33 | g_snprintf(str, sizeof(str) - 1, "%s" G_DIR_SEPARATOR_S ".silc", hd ? hd : "/tmp"); | |
| 34 | return (const char *)str; | |
| 35 | } | |
| 36 | ||
| 15884 | 37 | const char *silcpurple_session_file(const char *account) |
| 8849 | 38 | { |
| 39 | memset(str2, 0, sizeof(str2)); | |
| 40 | g_snprintf(str2, sizeof(str2) - 1, "%s" G_DIR_SEPARATOR_S "%s_session", | |
| 15884 | 41 | silcpurple_silcdir(), account); |
| 8849 | 42 | return (const char *)str2; |
| 43 | } | |
| 44 | ||
| 15884 | 45 | gboolean silcpurple_ip_is_private(const char *ip) |
| 8849 | 46 | { |
| 47 | if (silc_net_is_ip4(ip)) { | |
| 48 | if (!strncmp(ip, "10.", 3)) { | |
| 49 | return TRUE; | |
| 50 | } else if (!strncmp(ip, "172.", 4) && strlen(ip) > 6) { | |
| 51 | char tmp[3]; | |
| 8910 | 52 | int s; |
| 8849 | 53 | memset(tmp, 0, sizeof(tmp)); |
| 54 | strncpy(tmp, ip + 4, 2); | |
| 8910 | 55 | s = atoi(tmp); |
| 8849 | 56 | if (s >= 16 && s <= 31) |
| 57 | return TRUE; | |
| 58 | } else if (!strncmp(ip, "192.168.", 8)) { | |
| 59 | return TRUE; | |
| 60 | } | |
| 61 | } | |
| 62 | ||
| 63 | return FALSE; | |
| 64 | } | |
| 65 | ||
| 66 | /* This checks stats for various SILC files and directories. First it | |
| 67 | checks if ~/.silc directory exist and is owned by the correct user. If | |
| 68 | it doesn't exist, it will create the directory. After that it checks if | |
| 69 | user's Public and Private key files exists and creates them if needed. */ | |
| 70 | ||
| 15884 | 71 | gboolean silcpurple_check_silc_dir(PurpleConnection *gc) |
| 8849 | 72 | { |
| 73 | char filename[256], file_public_key[256], file_private_key[256]; | |
| 74 | char servfilename[256], clientfilename[256], friendsfilename[256]; | |
|
10825
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
75 | char pkd[256], prd[256]; |
| 8849 | 76 | struct stat st; |
| 77 | struct passwd *pw; | |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
78 | int fd; |
| 8849 | 79 | |
| 80 | pw = getpwuid(getuid()); | |
| 81 | if (!pw) { | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21115
diff
changeset
|
82 | purple_debug_error("silc", "silc: %s\n", g_strerror(errno)); |
| 8849 | 83 | return FALSE; |
| 84 | } | |
| 85 | ||
| 15884 | 86 | g_snprintf(filename, sizeof(filename) - 1, "%s", silcpurple_silcdir()); |
| 8849 | 87 | g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys", |
| 15884 | 88 | silcpurple_silcdir()); |
| 8849 | 89 | g_snprintf(clientfilename, sizeof(clientfilename) - 1, "%s" G_DIR_SEPARATOR_S "clientkeys", |
| 15884 | 90 | silcpurple_silcdir()); |
| 8849 | 91 | g_snprintf(friendsfilename, sizeof(friendsfilename) - 1, "%s" G_DIR_SEPARATOR_S "friends", |
| 15884 | 92 | silcpurple_silcdir()); |
| 8849 | 93 | |
| 94 | /* | |
| 95 | * Check ~/.silc directory | |
| 96 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
97 | if ((g_stat(filename, &st)) == -1) { |
| 8849 | 98 | /* If dir doesn't exist */ |
| 99 | if (errno == ENOENT) { | |
| 100 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
101 | if ((g_mkdir(filename, 0755)) == -1) { |
| 15884 | 102 | purple_debug_error("silc", "Couldn't create '%s' directory\n", filename); |
| 8849 | 103 | return FALSE; |
| 104 | } | |
| 105 | } else { | |
| 15884 | 106 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 107 | filename); |
| 108 | return FALSE; | |
| 109 | } | |
| 110 | } else { | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
21115
diff
changeset
|
111 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, g_strerror(errno)); |
| 8849 | 112 | return FALSE; |
| 113 | } | |
| 114 | } else { | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
115 | #ifndef _WIN32 |
| 8849 | 116 | /* Check the owner of the dir */ |
| 117 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { | |
| 15884 | 118 | purple_debug_error("silc", "You don't seem to own '%s' directory\n", |
| 8849 | 119 | filename); |
| 120 | return FALSE; | |
| 121 | } | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
122 | #endif |
| 8849 | 123 | } |
| 124 | ||
| 125 | /* | |
| 126 | * Check ~./silc/serverkeys directory | |
| 127 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
128 | if ((g_stat(servfilename, &st)) == -1) { |
| 8849 | 129 | /* If dir doesn't exist */ |
| 130 | if (errno == ENOENT) { | |
| 131 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
132 | if ((g_mkdir(servfilename, 0755)) == -1) { |
| 15884 | 133 | purple_debug_error("silc", "Couldn't create '%s' directory\n", servfilename); |
| 8849 | 134 | return FALSE; |
| 135 | } | |
| 136 | } else { | |
| 15884 | 137 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 138 | servfilename); |
| 139 | return FALSE; | |
| 140 | } | |
| 141 | } else { | |
| 15884 | 142 | 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:
21115
diff
changeset
|
143 | servfilename, g_strerror(errno)); |
| 8849 | 144 | return FALSE; |
| 145 | } | |
| 146 | } | |
| 147 | ||
| 148 | /* | |
| 149 | * Check ~./silc/clientkeys directory | |
| 150 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
151 | if ((g_stat(clientfilename, &st)) == -1) { |
| 8849 | 152 | /* If dir doesn't exist */ |
| 153 | if (errno == ENOENT) { | |
| 154 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
155 | if ((g_mkdir(clientfilename, 0755)) == -1) { |
| 15884 | 156 | purple_debug_error("silc", "Couldn't create '%s' directory\n", clientfilename); |
| 8849 | 157 | return FALSE; |
| 158 | } | |
| 159 | } else { | |
| 15884 | 160 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 161 | clientfilename); |
| 162 | return FALSE; | |
| 163 | } | |
| 164 | } else { | |
| 15884 | 165 | 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:
21115
diff
changeset
|
166 | clientfilename, g_strerror(errno)); |
| 8849 | 167 | return FALSE; |
| 168 | } | |
| 169 | } | |
| 170 | ||
| 171 | /* | |
| 172 | * Check ~./silc/friends directory | |
| 173 | */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
174 | if ((g_stat(friendsfilename, &st)) == -1) { |
| 8849 | 175 | /* If dir doesn't exist */ |
| 176 | if (errno == ENOENT) { | |
| 177 | if (pw->pw_uid == geteuid()) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
178 | if ((g_mkdir(friendsfilename, 0755)) == -1) { |
| 15884 | 179 | purple_debug_error("silc", "Couldn't create '%s' directory\n", friendsfilename); |
| 8849 | 180 | return FALSE; |
| 181 | } | |
| 182 | } else { | |
| 15884 | 183 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
| 8849 | 184 | friendsfilename); |
| 185 | return FALSE; | |
| 186 | } | |
| 187 | } else { | |
| 15884 | 188 | 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:
21115
diff
changeset
|
189 | friendsfilename, g_strerror(errno)); |
| 8849 | 190 | return FALSE; |
| 191 | } | |
| 192 | } | |
| 193 | ||
| 194 | /* | |
| 195 | * Check Public and Private keys | |
| 196 | */ | |
| 15884 | 197 | g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); |
| 198 | g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); | |
| 8849 | 199 | g_snprintf(file_public_key, sizeof(file_public_key) - 1, "%s", |
| 15884 | 200 | purple_account_get_string(gc->account, "public-key", pkd)); |
| 8849 | 201 | g_snprintf(file_private_key, sizeof(file_public_key) - 1, "%s", |
| 15884 | 202 | purple_account_get_string(gc->account, "private-key", prd)); |
| 8849 | 203 | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
9488
diff
changeset
|
204 | if ((g_stat(file_public_key, &st)) == -1) { |
| 8849 | 205 | /* If file doesn't exist */ |
| 206 | if (errno == ENOENT) { | |
| 15884 | 207 | purple_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); |
| 208 | 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
|
209 | 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
|
210 | 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
|
211 | 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
|
212 | (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
|
213 | ? "" : 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
|
214 | NULL, NULL, FALSE)) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
215 | purple_connection_error(gc, _("Cannot create SILC key pair\n")); |
|
14148
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
216 | return FALSE; |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
217 | } |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
218 | |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
219 | if ((g_stat(file_public_key, &st)) == -1) { |
| 15884 | 220 | 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:
21115
diff
changeset
|
221 | file_public_key, g_strerror(errno)); |
|
14148
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
222 | return FALSE; |
|
2f0c6fcb0db5
[gaim-migrate @ 16709]
Daniel Atallah <datallah@pidgin.im>
parents:
13660
diff
changeset
|
223 | } |
| 8849 | 224 | } else { |
| 15884 | 225 | 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:
21115
diff
changeset
|
226 | file_public_key, g_strerror(errno)); |
| 8849 | 227 | return FALSE; |
| 228 | } | |
| 229 | } | |
| 230 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
231 | #ifndef _WIN32 |
| 8849 | 232 | /* Check the owner of the public key */ |
| 233 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { | |
| 15884 | 234 | purple_debug_error("silc", "You don't seem to own your public key!?\n"); |
| 8849 | 235 | return FALSE; |
| 236 | } | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
237 | #endif |
| 8849 | 238 | |
|
14227
e760c7dd2e7a
[gaim-migrate @ 16815]
Daniel Atallah <datallah@pidgin.im>
parents:
14218
diff
changeset
|
239 | 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
|
240 | if ((fstat(fd, &st)) == -1) { |
| 15884 | 241 | 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:
21115
diff
changeset
|
242 | file_private_key, g_strerror(errno)); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
243 | close(fd); |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
244 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
245 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
246 | } else if ((g_stat(file_private_key, &st)) == -1) { |
| 8849 | 247 | /* If file doesn't exist */ |
| 248 | if (errno == ENOENT) { | |
| 15884 | 249 | purple_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); |
| 250 | 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
|
251 | 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
|
252 | 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
|
253 | 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
|
254 | (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
|
255 | ? "" : 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
|
256 | NULL, NULL, FALSE)) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
257 | purple_connection_error(gc, _("Cannot create SILC key pair\n")); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
258 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
259 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
260 | |
|
14227
e760c7dd2e7a
[gaim-migrate @ 16815]
Daniel Atallah <datallah@pidgin.im>
parents:
14218
diff
changeset
|
261 | 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
|
262 | if ((fstat(fd, &st)) == -1) { |
| 15884 | 263 | 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:
21115
diff
changeset
|
264 | file_private_key, g_strerror(errno)); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
265 | close(fd); |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
266 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
267 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
268 | } |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
269 | /* This shouldn't really happen because silc_create_key_pair() |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
270 | * will set the permissions */ |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
271 | else if ((g_stat(file_private_key, &st)) == -1) { |
| 15884 | 272 | 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:
21115
diff
changeset
|
273 | file_private_key, g_strerror(errno)); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
274 | return FALSE; |
|
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
275 | } |
| 8849 | 276 | } else { |
| 15884 | 277 | 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:
21115
diff
changeset
|
278 | file_private_key, g_strerror(errno)); |
| 8849 | 279 | return FALSE; |
| 280 | } | |
| 281 | } | |
| 282 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
283 | #ifndef _WIN32 |
| 8849 | 284 | /* Check the owner of the private key */ |
| 285 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { | |
| 15884 | 286 | 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
|
287 | if (fd != -1) |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
288 | close(fd); |
| 8849 | 289 | return FALSE; |
| 290 | } | |
| 291 | ||
| 292 | /* Check the permissions for the private key */ | |
| 293 | if ((st.st_mode & 0777) != 0600) { | |
| 15884 | 294 | 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
|
295 | "Trying to change them ...\n", file_private_key); |
|
14218
c498aba6235f
[gaim-migrate @ 16801]
Daniel Atallah <datallah@pidgin.im>
parents:
14148
diff
changeset
|
296 | if ((fd == -1) || (fchmod(fd, S_IRUSR | S_IWUSR)) == -1) { |
| 15884 | 297 | purple_debug_error("silc", |
| 8849 | 298 | "Failed to change permissions for private key file!\n" |
| 299 | "Permissions for your private key file must be 0600.\n"); | |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
300 | if (fd != -1) |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
301 | close(fd); |
| 8849 | 302 | return FALSE; |
| 303 | } | |
| 15884 | 304 | purple_debug_warning("silc", "Done.\n\n"); |
| 8849 | 305 | } |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
306 | #endif |
| 8849 | 307 | |
|
13660
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
308 | if (fd != -1) |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
309 | close(fd); |
|
3ade3ab0b2ae
[gaim-migrate @ 16061]
Mark Doliner <markdoliner@pidgin.im>
parents:
13546
diff
changeset
|
310 | |
| 8849 | 311 | return TRUE; |
| 312 | } | |
| 313 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
314 | #ifdef _WIN32 |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
315 | struct passwd *getpwuid(uid_t uid) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
316 | struct passwd *pwd = calloc(1, sizeof(struct passwd)); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
317 | return pwd; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
318 | } |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
319 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
320 | uid_t getuid() { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
321 | return 0; |
|
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 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
324 | uid_t geteuid() { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
325 | return 0; |
|
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 | #endif |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9274
diff
changeset
|
328 | |
| 15884 | 329 | 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
|
330 | 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
|
331 | GCallback callback, void *context) |
| 8849 | 332 | { |
| 333 | 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
|
334 | SilcSILCPublicKey silc_pubkey; |
| 8849 | 335 | char *fingerprint, *babbleprint; |
| 336 | unsigned char *pk; | |
| 337 | SilcUInt32 pk_len, key_len = 0; | |
| 338 | GString *s; | |
| 339 | char *buf; | |
| 340 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
341 | /* 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
|
342 | 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
|
343 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
344 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
345 | 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
|
346 | 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
|
347 | key_len = silc_pkcs_public_key_get_len(public_key); |
| 8849 | 348 | |
| 349 | pk = silc_pkcs_public_key_encode(public_key, &pk_len); | |
|
21115
1cf273ed6eda
Patch from Pekka Riikone to fix various SILC issues.
Ethan Blanton <elb@pidgin.im>
parents:
18552
diff
changeset
|
350 | if (!pk) |
|
1cf273ed6eda
Patch from Pekka Riikone to fix various SILC issues.
Ethan Blanton <elb@pidgin.im>
parents:
18552
diff
changeset
|
351 | return; |
| 8849 | 352 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); |
| 353 | babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); | |
|
21115
1cf273ed6eda
Patch from Pekka Riikone to fix various SILC issues.
Ethan Blanton <elb@pidgin.im>
parents:
18552
diff
changeset
|
354 | if (!fingerprint || !babbleprint) |
|
1cf273ed6eda
Patch from Pekka Riikone to fix various SILC issues.
Ethan Blanton <elb@pidgin.im>
parents:
18552
diff
changeset
|
355 | return; |
| 8849 | 356 | |
| 357 | s = g_string_new(""); | |
| 358 | if (ident->realname) | |
|
10825
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
359 | /* Hint for translators: Please check the tabulator width here and in |
|
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
360 | the next strings (short strings: 2 tabs, longer strings 1 tab, |
| 9274 | 361 | sum: 3 tabs or 24 characters) */ |
| 362 | g_string_append_printf(s, _("Real Name: \t%s\n"), ident->realname); | |
| 8849 | 363 | if (ident->username) |
| 9274 | 364 | g_string_append_printf(s, _("User Name: \t%s\n"), ident->username); |
| 8849 | 365 | if (ident->email) |
|
13546
0700f0c29e14
[gaim-migrate @ 15922]
Richard Laager <rlaager@pidgin.im>
parents:
12217
diff
changeset
|
366 | g_string_append_printf(s, _("E-Mail: \t\t%s\n"), ident->email); |
| 8849 | 367 | if (ident->host) |
| 9274 | 368 | g_string_append_printf(s, _("Host Name: \t%s\n"), ident->host); |
| 8849 | 369 | if (ident->org) |
| 9274 | 370 | g_string_append_printf(s, _("Organization: \t%s\n"), ident->org); |
| 8849 | 371 | if (ident->country) |
| 9274 | 372 | 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
|
373 | g_string_append_printf(s, _("Algorithm: \t%s\n"), silc_pubkey->pkcs->name); |
| 9274 | 374 | 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
|
375 | 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
|
376 | g_string_append_printf(s, _("Version: \t%s\n"), ident->version); |
| 9274 | 377 | g_string_append_printf(s, "\n"); |
| 378 | g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint); | |
| 379 | g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint); | |
| 8849 | 380 | |
| 381 | buf = g_string_free(s, FALSE); | |
| 382 | ||
| 15884 | 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"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
385 | buf, 0, purple_connection_get_account(sg->gc), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
386 | NULL, NULL, context, 1, _("Close"), callback); |
| 8849 | 387 | |
| 388 | g_free(buf); | |
| 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] "); | |
| 443 | } | |
| 444 | ||
| 15884 | 445 | 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
|
446 | SilcUInt32 buf_size) |
| 8849 | 447 | { |
| 448 | memset(buf, 0, buf_size); | |
| 449 | if (mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) | |
| 450 | strcat(buf, "[permanent] "); | |
| 451 | if (mode & SILC_CHANNEL_MODE_PRIVATE) | |
| 452 | strcat(buf, "[private] "); | |
| 453 | if (mode & SILC_CHANNEL_MODE_SECRET) | |
| 454 | strcat(buf, "[secret] "); | |
| 455 | if (mode & SILC_CHANNEL_MODE_PRIVKEY) | |
| 456 | strcat(buf, "[private key] "); | |
| 457 | if (mode & SILC_CHANNEL_MODE_INVITE) | |
| 458 | strcat(buf, "[invite only] "); | |
| 459 | if (mode & SILC_CHANNEL_MODE_TOPIC) | |
| 460 | strcat(buf, "[topic restricted] "); | |
| 461 | if (mode & SILC_CHANNEL_MODE_ULIMIT) | |
| 462 | strcat(buf, "[user count limit] "); | |
| 463 | if (mode & SILC_CHANNEL_MODE_PASSPHRASE) | |
| 464 | strcat(buf, "[passphrase auth] "); | |
| 465 | if (mode & SILC_CHANNEL_MODE_CHANNEL_AUTH) | |
| 466 | strcat(buf, "[public key auth] "); | |
| 467 | if (mode & SILC_CHANNEL_MODE_SILENCE_USERS) | |
| 468 | strcat(buf, "[users silenced] "); | |
| 469 | if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS) | |
| 470 | strcat(buf, "[operators silenced] "); | |
| 471 | } | |
| 472 | ||
| 15884 | 473 | void silcpurple_get_chumode_string(SilcUInt32 mode, char *buf, |
| 8849 | 474 | SilcUInt32 buf_size) |
| 475 | { | |
| 476 | memset(buf, 0, buf_size); | |
| 477 | if (mode & SILC_CHANNEL_UMODE_CHANFO) | |
| 478 | strcat(buf, "[founder] "); | |
| 479 | if (mode & SILC_CHANNEL_UMODE_CHANOP) | |
| 480 | strcat(buf, "[operator] "); | |
| 481 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES) | |
| 482 | strcat(buf, "[blocks messages] "); | |
| 483 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_USERS) | |
| 484 | strcat(buf, "[blocks user messages] "); | |
| 485 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_ROBOTS) | |
| 486 | strcat(buf, "[blocks robot messages] "); | |
| 487 | if (mode & SILC_CHANNEL_UMODE_QUIET) | |
| 488 | strcat(buf, "[quieted] "); | |
| 489 | } | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
490 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
491 | void |
| 15884 | 492 | 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
|
493 | 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
|
494 | char **tzstr, char **geostr) |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
495 | { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
496 | SilcAttributePayload attr; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
497 | SilcAttributeMood mood = 0; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
498 | SilcAttributeContact contact; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
499 | SilcAttributeObjDevice device; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
500 | SilcAttributeObjGeo geo; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
501 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
502 | char tmp[1024]; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
503 | GString *s; |
|
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 | *moodstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
506 | *statusstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
507 | *contactstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
508 | *langstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
509 | *devicestr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
510 | *tzstr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
511 | *geostr = NULL; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
512 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
513 | if (!attrs) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
514 | return; |
|
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 | s = g_string_new(""); |
| 15884 | 517 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_MOOD); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
518 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
519 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
520 | g_string_append_printf(s, "[%s] ", _("Happy")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
521 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
522 | g_string_append_printf(s, "[%s] ", _("Sad")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
523 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
524 | g_string_append_printf(s, "[%s] ", _("Angry")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
525 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
526 | g_string_append_printf(s, "[%s] ", _("Jealous")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
527 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
528 | g_string_append_printf(s, "[%s] ", _("Ashamed")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
529 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
530 | g_string_append_printf(s, "[%s] ", _("Invincible")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
531 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
532 | g_string_append_printf(s, "[%s] ", _("In Love")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
533 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
534 | g_string_append_printf(s, "[%s] ", _("Sleepy")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
535 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
536 | g_string_append_printf(s, "[%s] ", _("Bored")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
537 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
538 | g_string_append_printf(s, "[%s] ", _("Excited")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
539 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
540 | g_string_append_printf(s, "[%s] ", _("Anxious")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
541 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
542 | if (strlen(s->str)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
543 | *moodstr = s->str; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
544 | g_string_free(s, FALSE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
545 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
546 | g_string_free(s, TRUE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
547 | |
| 15884 | 548 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
549 | memset(tmp, 0, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
550 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
551 | *statusstr = g_strdup(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
552 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
553 | s = g_string_new(""); |
| 15884 | 554 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_CONTACT); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
555 | if (attr && silc_attribute_get_object(attr, &contact, sizeof(contact))) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
556 | if (contact & SILC_ATTRIBUTE_CONTACT_CHAT) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
557 | g_string_append_printf(s, "[%s] ", _("Chat")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
558 | if (contact & SILC_ATTRIBUTE_CONTACT_EMAIL) |
|
13546
0700f0c29e14
[gaim-migrate @ 15922]
Richard Laager <rlaager@pidgin.im>
parents:
12217
diff
changeset
|
559 | g_string_append_printf(s, "[%s] ", _("E-Mail")); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
560 | if (contact & SILC_ATTRIBUTE_CONTACT_CALL) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
561 | g_string_append_printf(s, "[%s] ", _("Phone")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
562 | if (contact & SILC_ATTRIBUTE_CONTACT_PAGE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
563 | g_string_append_printf(s, "[%s] ", _("Paging")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
564 | if (contact & SILC_ATTRIBUTE_CONTACT_SMS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
565 | g_string_append_printf(s, "[%s] ", _("SMS")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
566 | if (contact & SILC_ATTRIBUTE_CONTACT_MMS) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
567 | g_string_append_printf(s, "[%s] ", _("MMS")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
568 | if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
569 | g_string_append_printf(s, "[%s] ", _("Video Conferencing")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
570 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
571 | if (strlen(s->str)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
572 | *contactstr = s->str; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
573 | g_string_free(s, FALSE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
574 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
575 | g_string_free(s, TRUE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
576 | |
| 15884 | 577 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
578 | memset(tmp, 0, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
579 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
580 | *langstr = g_strdup(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
581 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
582 | s = g_string_new(""); |
| 15884 | 583 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_DEVICE_INFO); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
584 | memset(&device, 0, sizeof(device)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
585 | if (attr && silc_attribute_get_object(attr, &device, sizeof(device))) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
586 | if (device.type == SILC_ATTRIBUTE_DEVICE_COMPUTER) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
587 | g_string_append_printf(s, "%s: ", _("Computer")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
588 | if (device.type == SILC_ATTRIBUTE_DEVICE_MOBILE_PHONE) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
589 | g_string_append_printf(s, "%s: ", _("Mobile Phone")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
590 | if (device.type == SILC_ATTRIBUTE_DEVICE_PDA) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
591 | g_string_append_printf(s, "%s: ", _("PDA")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
592 | if (device.type == SILC_ATTRIBUTE_DEVICE_TERMINAL) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
593 | g_string_append_printf(s, "%s: ", _("Terminal")); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
594 | g_string_append_printf(s, "%s %s %s %s", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
595 | device.manufacturer ? device.manufacturer : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
596 | device.version ? device.version : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
597 | device.model ? device.model : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
598 | device.language ? device.language : ""); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
599 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
600 | if (strlen(s->str)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
601 | *devicestr = s->str; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
602 | g_string_free(s, FALSE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
603 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
604 | g_string_free(s, TRUE); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
605 | |
| 15884 | 606 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
607 | memset(tmp, 0, sizeof(tmp)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
608 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
609 | *tzstr = g_strdup(tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
610 | |
| 15884 | 611 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_GEOLOCATION); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
612 | memset(&geo, 0, sizeof(geo)); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
613 | if (attr && silc_attribute_get_object(attr, &geo, sizeof(geo))) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
614 | *geostr = g_strdup_printf("%s %s %s (%s)", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
615 | geo.longitude ? geo.longitude : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
616 | geo.latitude ? geo.latitude : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
617 | geo.altitude ? geo.altitude : "", |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
618 | geo.accuracy ? geo.accuracy : ""); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
619 | } |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
620 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
621 | /* Returns MIME type of filetype */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
622 | |
| 15884 | 623 | char *silcpurple_file2mime(const char *filename) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
624 | { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
625 | const char *ct; |
|
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 | ct = strrchr(filename, '.'); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
628 | if (!ct) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
629 | 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
|
630 | else if (!g_ascii_strcasecmp(".png", ct)) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
631 | return 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
|
632 | else if (!g_ascii_strcasecmp(".jpg", ct)) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
633 | return 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
|
634 | else if (!g_ascii_strcasecmp(".jpeg", ct)) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
635 | return 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(".gif", ct)) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
637 | return 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
|
638 | else if (!g_ascii_strcasecmp(".tiff", ct)) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
639 | return 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
|
640 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
641 | return NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
642 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
643 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17156
diff
changeset
|
644 | /* 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
|
645 | 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
|
646 | 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
|
647 | message is created. */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
648 | |
| 15884 | 649 | SilcDList silcpurple_image_message(const char *msg, SilcUInt32 *mflags) |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
650 | { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
651 | SilcMime mime = NULL, p; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
652 | SilcDList list, parts = NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
653 | const char *start, *end, *last; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
654 | GData *attribs; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
655 | char *type; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
656 | gboolean images = FALSE; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
657 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
658 | last = msg; |
| 15884 | 659 | while (last && *last && purple_markup_find_tag("img", last, &start, |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
660 | &end, &attribs)) { |
| 15884 | 661 | PurpleStoredImage *image = NULL; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
662 | const char *id; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
663 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
664 | /* Check if there is text before image */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
665 | if (start - last) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
666 | char *text, *tmp; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
667 | p = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
668 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
669 | /* Add content type */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
670 | silc_mime_add_field(p, "Content-Type", |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
671 | "text/plain; charset=utf-8"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
672 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
673 | tmp = g_strndup(last, start - last); |
| 15884 | 674 | text = purple_unescape_html(tmp); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
675 | 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
|
676 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
677 | /* 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
|
678 | 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
|
679 | g_free(text); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
680 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
681 | if (!parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
682 | parts = silc_dlist_init(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
683 | silc_dlist_add(parts, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
684 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
685 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
686 | 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
|
687 | if (id && (image = purple_imgstore_find_by_id(atoi(id)))) { |
| 15884 | 688 | 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
|
689 | gconstpointer img = purple_imgstore_get_data(image); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
690 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
691 | p = silc_mime_alloc(); |
|
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 | /* Add content type */ |
| 15884 | 694 | type = silcpurple_file2mime(purple_imgstore_get_filename(image)); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
695 | if (!type) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
696 | g_datalist_clear(&attribs); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
697 | last = end + 1; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
698 | continue; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
699 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
700 | silc_mime_add_field(p, "Content-Type", type); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
701 | silc_free(type); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
702 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
703 | /* Add content transfer encoding */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
704 | silc_mime_add_field(p, "Content-Transfer-Encoding", "binary"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
705 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
706 | /* Add image data */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
707 | silc_mime_add_data(p, img, imglen); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
708 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
709 | if (!parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
710 | parts = silc_dlist_init(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
711 | silc_dlist_add(parts, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
712 | images = TRUE; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
713 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
714 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
715 | g_datalist_clear(&attribs); |
|
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 | /* Continue after tag */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
718 | last = end + 1; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
719 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
720 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
721 | /* Check for text after the image(s) */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
722 | if (images && last && *last) { |
| 15884 | 723 | char *tmp = purple_unescape_html(last); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
724 | p = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
725 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
726 | /* Add content type */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
727 | silc_mime_add_field(p, "Content-Type", |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
728 | "text/plain; charset=utf-8"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
729 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
730 | /* 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
|
731 | 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
|
732 | g_free(tmp); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
733 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
734 | if (!parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
735 | parts = silc_dlist_init(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
736 | silc_dlist_add(parts, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
737 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
738 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
739 | /* If there weren't any images, don't return anything. */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
740 | if (!images) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
741 | if (parts) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
742 | silc_dlist_uninit(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
743 | return NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
744 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
745 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
746 | if (silc_dlist_count(parts) > 1) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
747 | /* Multipart MIME message */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
748 | char b[32]; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
749 | mime = silc_mime_alloc(); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
750 | silc_mime_add_field(mime, "MIME-Version", "1.0"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
751 | g_snprintf(b, sizeof(b), "b%4X%4X", |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
752 | (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
|
753 | silc_dlist_count(parts)); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
754 | silc_mime_set_multipart(mime, "mixed", b); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
755 | silc_dlist_start(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
756 | while ((p = silc_dlist_get(parts)) != SILC_LIST_END) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
757 | silc_mime_add_multipart(mime, p); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
758 | } else { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
759 | /* Simple MIME message */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
760 | silc_dlist_start(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
761 | mime = silc_dlist_get(parts); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
762 | silc_mime_add_field(mime, "MIME-Version", "1.0"); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
763 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
764 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
765 | *mflags &= ~SILC_MESSAGE_FLAG_UTF8; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
766 | *mflags |= SILC_MESSAGE_FLAG_DATA; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
767 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
768 | /* Encode message. Fragment if it is too large */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
769 | list = silc_mime_encode_partial(mime, 0xfc00); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
770 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
771 | silc_dlist_uninit(parts); |
|
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 | /* Added multiparts gets freed here */ |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
774 | silc_mime_free(mime); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
775 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
776 | return list; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
11488
diff
changeset
|
777 | } |