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