annotate mcabber/src/settings.c @ 1068:6646d2ed7f74

Allow pgp commands in config file, update sample configuration file
author Mikael Berthe <mikael@lilotux.net>
date Sat, 02 Dec 2006 13:29:56 +0100
parents 230dca34dbea
children 9eaacc0ad3a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
1 /*
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
2 * settings.c -- Configuration stuff
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 378
diff changeset
3 *
699
ee03b56b93ee Update Copyright (2006)
Mikael Berthe <mikael@lilotux.net>
parents: 580
diff changeset
4 * Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.lilotux.net>
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
5 *
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or (at
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
9 * your option) any later version.
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
10 *
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
14 * General Public License for more details.
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
15 *
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
19 * USA
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
20 */
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
21
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
22 #include <strings.h>
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
23 #include <stdlib.h>
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
24 #include <ctype.h>
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
25
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
26 #include "settings.h"
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
27 #include "commands.h"
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
28 #include "utils.h"
378
2e6c7b1440d1 Improve debugging/logging
Mikael Berthe <mikael@lilotux.net>
parents: 374
diff changeset
29 #include "logprint.h"
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
30
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
31 static GSList *option;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
32 static GSList *alias;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
33 static GSList *binding;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
34
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
35 typedef struct {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
36 gchar *name;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
37 gchar *value;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
38 } T_setting;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
39
1065
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
40 #ifdef HAVE_GPGME /* PGP settings */
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
41 static GHashTable *pgpopt;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
42
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
43 typedef struct {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
44 gchar *pgp_keyid; /* KeyId the contact is supposed to use */
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
45 guint pgp_disabled; /* If TRUE, PGP is disabled for outgoing messages */
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
46 } T_pgpopt;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
47 #endif
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
48
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 294
diff changeset
49 static inline GSList **get_list_ptr(guint type)
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
50 {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
51 if (type == SETTINGS_TYPE_OPTION) return &option;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
52 else if (type == SETTINGS_TYPE_ALIAS) return &alias;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
53 else if (type == SETTINGS_TYPE_BINDING) return &binding;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
54 return NULL;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
55 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
56
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
57 // Return a pointer to the node with the requested key, or NULL if none found
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 294
diff changeset
58 static GSList *settings_find(GSList *list, const gchar *key)
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
59 {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
60 GSList *ptr;
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 378
diff changeset
61
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
62 if (!list) return NULL;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
63
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
64 for (ptr = list ; ptr; ptr = g_slist_next(ptr))
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
65 if (!strcasecmp(key, ((T_setting*)ptr->data)->name))
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
66 break;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
67
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
68 return ptr;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
69 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
70
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
71 /* -- */
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
72
1065
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
73 void settings_init(void)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
74 {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
75 #ifdef HAVE_GPGME
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
76 pgpopt = g_hash_table_new(&g_str_hash, &g_str_equal);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
77 #endif
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
78 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
79
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
80 // cfg_read_file(filename)
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
81 // Read and parse config file "filename". If filename is NULL,
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
82 // try to open the configuration file at the default locations.
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
83 //
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
84 int cfg_read_file(char *filename)
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
85 {
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
86 FILE *fp;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
87 char *buf;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
88 char *line, *eol;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
89 unsigned int ln = 0;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
90 int err = 0;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
91
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
92 if (!filename) {
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
93 // Use default config file locations
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
94 char *home = getenv("HOME");
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
95 if (!home) {
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 364
diff changeset
96 scr_LogPrint(LPRINT_LOG, "Can't find home dir!");
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
97 fprintf(stderr, "Can't find home dir!\n");
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
98 return -1;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
99 }
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
100 filename = g_new(char, strlen(home)+24);
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
101 sprintf(filename, "%s/.mcabber/mcabberrc", home);
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
102 if ((fp = fopen(filename, "r")) == NULL) {
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
103 // 2nd try...
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
104 sprintf(filename, "%s/.mcabberrc", home);
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
105 if ((fp = fopen(filename, "r")) == NULL) {
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
106 fprintf(stderr, "Cannot open config file!\n");
895
b461d7ee6d96 Minor changes
Mikael Berthe <mikael@lilotux.net>
parents: 872
diff changeset
107 g_free(filename);
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
108 return -1;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
109 }
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
110 }
362
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
111 // Check configuration file permissions
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
112 // As it could contain sensitive data, we make it user-readable only
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
113 checkset_perm(filename, TRUE);
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
114 // Check mcabber dir. There we just warn, we don't change the modes
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
115 sprintf(filename, "%s/.mcabber/", home);
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
116 checkset_perm(filename, FALSE);
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
117 g_free(filename);
362
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
118 } else {
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
119 if ((fp = fopen(filename, "r")) == NULL) {
780
1dd19363c73e cfg_read_file(): Clarify error message
Mikael Berthe <mikael@lilotux.net>
parents: 774
diff changeset
120 perror("Cannot open configuration file");
872
a0ddc43b421e Don't stop when there is no configuration file
Mikael Berthe <mikael@lilotux.net>
parents: 867
diff changeset
121 return -2;
362
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
122 }
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
123 // Check configuration file permissions (see above)
d8f147d6e872 Check directory and config file permissions
Mikael Berthe <mikael@lilotux.net>
parents: 341
diff changeset
124 checkset_perm(filename, TRUE);
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
125 }
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
126
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
127 buf = g_new(char, 512);
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
128
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
129 while (fgets(buf+1, 511, fp) != NULL) {
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
130 // The first char is reserved to add a '/', to make a command line
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
131 line = buf+1;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
132 ln++;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
133
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
134 // Strip leading spaces
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
135 while (isspace(*line))
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
136 line++;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
137
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
138 // Make eol point to the last char of the line
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
139 for (eol = line ; *eol ; eol++)
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
140 ;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
141 if (eol > line)
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
142 eol--;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
143
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
144 // Strip trailing spaces
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
145 while (eol > line && isspace(*eol))
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
146 *eol-- = 0;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
147
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
148 // Ignore empty lines and comments
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
149 if ((*line == '\n') || (*line == '\0') || (*line == '#'))
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
150 continue;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
151
1068
6646d2ed7f74 Allow pgp commands in config file, update sample configuration file
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
152 if ((strchr(line, '=') != NULL) || !strncmp(line, "pgp ", strlen("pgp "))) {
6646d2ed7f74 Allow pgp commands in config file, update sample configuration file
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
153 // Only accept the set, alias, bind and pgp commands
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
154 if (strncmp(line, "set ", strlen("set ")) &&
1068
6646d2ed7f74 Allow pgp commands in config file, update sample configuration file
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
155 strncmp(line, "pgp ", strlen("pgp ")) &&
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
156 strncmp(line, "bind ", strlen("bind ")) &&
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
157 strncmp(line, "alias ", strlen("alias "))) {
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 364
diff changeset
158 scr_LogPrint(LPRINT_LOGNORM,
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 364
diff changeset
159 "Error in configuration file (l. %d): bad command", ln);
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
160 err++;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
161 continue;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
162 }
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
163 // Set the leading COMMAND_CHAR to build a command line
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
164 // and process the command
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
165 *(--line) = COMMAND_CHAR;
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 895
diff changeset
166 process_command(line);
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
167 } else {
374
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 364
diff changeset
168 scr_LogPrint(LPRINT_LOGNORM,
bd5638c21834 Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents: 364
diff changeset
169 "Error in configuration file (l. %d): no assignment", ln);
341
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
170 err++;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
171 }
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
172 }
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
173 g_free(buf);
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
174 fclose(fp);
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
175 return err;
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
176 }
dea407d53fe6 Improve configuration file reading
Mikael Berthe <mikael@lilotux.net>
parents: 337
diff changeset
177
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
178 // parse_assigment(assignment, pkey, pval)
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
179 // Read assignment and split it to key, value
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
180 //
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
181 // If this is an assignment, the function will return TRUE and
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
182 // set *pkey and *pval (*pval is set to NULL if value field is empty).
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
183 //
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
184 // If this isn't a assignment (no = char), the function will set *pval
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
185 // to NULL and return FALSE.
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
186 //
774
46304b773a44 Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
187 // The caller should g_free() *pkey and *pval (if not NULL) after use.
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 280
diff changeset
188 guint parse_assigment(gchar *assignment, const gchar **pkey, const gchar **pval)
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
189 {
293
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
190 char *key, *val, *t, *p;
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
191
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
192 *pkey = *pval = NULL;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
193
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
194 key = assignment;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
195 // Remove leading spaces in option name
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
196 while ((!isalnum(*key)) && (*key != '=') && *key) {
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
197 //if (!isblank(*key))
293
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
198 // scr_LogPrint("Error in assignment parsing!");
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
199 key++;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
200 }
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
201 if (!*key) return FALSE; // Empty assignment
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
202
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
203 if (*key == '=') {
293
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
204 //scr_LogPrint("Cannot parse assignment!");
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
205 return FALSE;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
206 }
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
207 // Ok, key points to the option name
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
208
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
209 for (val = key+1 ; *val && (*val != '=') ; val++)
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
210 if (!isalnum(*val) && !isblank(*val) && (*val != '_') && (*val != '-')) {
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
211 // Key should only have alnum chars...
293
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
212 //scr_LogPrint("Error in assignment parsing!");
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
213 return FALSE;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
214 }
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
215 // Remove trailing spaces in option name:
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
216 for (t = val-1 ; t > key && isblank(*t) ; t--)
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
217 ;
293
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
218 // Check for embedded whitespace characters
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
219 for (p = key; p < t; p++) {
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
220 if (isblank(*p)) {
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
221 //scr_LogPrint("Error in assignment parsing!"
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
222 // " (Name should not contain space chars)");
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
223 return FALSE;
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
224 }
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
225 }
d0295e735768 Assignment lvalue (key, option name, alias...) cannnot contain spaces
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
226
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
227 *pkey = g_strndup(key, t+1-key);
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
228
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
229 if (!*val) return FALSE; // Not an assignment
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
230
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
231 // Remove leading and trailing spaces in option value:
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
232 for (val++; *val && isblank(*val) ; val++) ;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
233 for (t = val ; *t ; t++) ;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
234 for (t-- ; t >= val && isblank(*t) ; t--) ;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
235
282
87d6ac21cd1b Fix "Cannot unset option" bug
Mikael Berthe <mikael@lilotux.net>
parents: 281
diff changeset
236 if (t < val) return TRUE; // no value (variable reset for example)
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
237
337
3a25be278864 Values can be enclosed by quotes in assignments
Mikael Berthe <mikael@lilotux.net>
parents: 336
diff changeset
238 // If the value begins and ends with quotes ("), these quotes are
3a25be278864 Values can be enclosed by quotes in assignments
Mikael Berthe <mikael@lilotux.net>
parents: 336
diff changeset
239 // removed and whitespace is not stripped
3a25be278864 Values can be enclosed by quotes in assignments
Mikael Berthe <mikael@lilotux.net>
parents: 336
diff changeset
240 if ((t>val) && (*val == '"' && *t == '"')) {
3a25be278864 Values can be enclosed by quotes in assignments
Mikael Berthe <mikael@lilotux.net>
parents: 336
diff changeset
241 val++;
3a25be278864 Values can be enclosed by quotes in assignments
Mikael Berthe <mikael@lilotux.net>
parents: 336
diff changeset
242 t--;
3a25be278864 Values can be enclosed by quotes in assignments
Mikael Berthe <mikael@lilotux.net>
parents: 336
diff changeset
243 }
280
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
244 *pval = g_strndup(val, t+1-val);
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
245 return TRUE;
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
246 }
68ce34b4243b Add parse_assigment() function
Mikael Berthe <mikael@lilotux.net>
parents: 279
diff changeset
247
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 280
diff changeset
248 void settings_set(guint type, const gchar *key, const gchar *value)
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
249 {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
250 GSList **plist;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
251 GSList *sptr;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
252 T_setting *setting;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
253
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
254 plist = get_list_ptr(type);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
255 if (!plist) return;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
256
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
257 sptr = settings_find(*plist, key);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
258 if (sptr) {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
259 // The setting has been found. We will update it or delete it.
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
260 setting = (T_setting*)sptr->data;
774
46304b773a44 Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents: 764
diff changeset
261 g_free(setting->value);
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
262 if (!value) {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
263 // Let's remove the setting
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
264 g_free(setting->name);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
265 *plist = g_slist_delete_link(*plist, sptr);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
266 } else {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
267 // Let's update the setting
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
268 setting->value = g_strdup(value);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
269 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
270 } else if (value) {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
271 setting = g_new(T_setting, 1);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
272 setting->name = g_strdup(key);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
273 setting->value = g_strdup(value);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
274 *plist = g_slist_append(*plist, setting);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
275 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
276 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
277
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 280
diff changeset
278 void settings_del(guint type, const gchar *key)
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
279 {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
280 settings_set(type, key, NULL);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
281 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
282
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 280
diff changeset
283 const gchar *settings_get(guint type, const gchar *key)
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
284 {
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
285 GSList **plist;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
286 GSList *sptr;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
287 T_setting *setting;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
288
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
289 plist = get_list_ptr(type);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
290 sptr = settings_find(*plist, key);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
291 if (!sptr) return NULL;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
292
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
293 setting = (T_setting*)sptr->data;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
294 return setting->value;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
295 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
296
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 280
diff changeset
297 int settings_get_int(guint type, const gchar *key)
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
298 {
281
f562b9af2de7 Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents: 280
diff changeset
299 const gchar *setval = settings_get(type, key);
279
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
300
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
301 if (setval) return atoi(setval);
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
302 return 0;
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
303 }
f5dd437c057b Rewrite the settings system
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
304
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
305 // settings_get_status_msg(status)
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
306 // Return a string with the current status message:
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
307 // - if there is a user-defined message ("message" option),
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
308 // return this message
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
309 // - if there is a user-defined message for the given status (and no
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
310 // generic user message), it is returned
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
311 // - if no message is found, return NULL
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
312 const gchar *settings_get_status_msg(enum imstatus status)
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
313 {
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
314 const gchar *rstatus = settings_opt_get("message");
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
315
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
316 if (rstatus) return rstatus;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
317
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
318 switch(status) {
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
319 case available:
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
320 rstatus = settings_opt_get("message_avail");
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
321 break;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
322
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
323 case freeforchat:
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
324 rstatus = settings_opt_get("message_free");
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
325 break;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
326
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
327 case dontdisturb:
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
328 rstatus = settings_opt_get("message_dnd");
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
329 break;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
330
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
331 case notavail:
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
332 rstatus = settings_opt_get("message_notavail");
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
333 break;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
334
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
335 case away:
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
336 rstatus = settings_opt_get("message_away");
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
337 break;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
338
521
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
339 default: // offline, invisible
cc8c969ab6e5 "/status" changes
Mikael Berthe <mikael@lilotux.net>
parents: 393
diff changeset
340 break;
294
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
341 }
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
342 return rstatus;
871e53769084 Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents: 293
diff changeset
343 }
576
8b3db0b555a1 Add Vim modelines
Mikael Berthe <mikael@lilotux.net>
parents: 521
diff changeset
344
867
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
345 // settings_foreach(type, pfunction, param)
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
346 // Call pfunction(param, key, value) for each setting with requested type.
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
347 void settings_foreach(guint type, void (*pfunc)(void *param, char *k, char *v),
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
348 void *param)
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
349 {
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
350 GSList **plist;
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
351 GSList *ptr;
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
352 T_setting *setting;
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
353
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
354 plist = get_list_ptr(type);
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
355
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
356 if (!*plist) return;
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
357
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
358 for (ptr = *plist ; ptr; ptr = g_slist_next(ptr)) {
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
359 setting = ptr->data;
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
360 pfunc(param, setting->name, setting->value);
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
361 }
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
362 }
7f056c566569 Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents: 780
diff changeset
363
1004
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
364
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
365 // default_muc_nickname()
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
366 // Return the user's default nickname
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
367 // The caller should free the string after use
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
368 char *default_muc_nickname(void)
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
369 {
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
370 char *nick;
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
371
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
372 // We try the "nickname" option, then the username part of the jid.
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
373 nick = (char*)settings_opt_get("nickname");
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
374 if (nick)
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
375 return g_strdup(nick);
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
376
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
377 nick = g_strdup(settings_opt_get("username"));
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
378 if (nick) {
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
379 char *p = strchr(nick, JID_DOMAIN_SEPARATOR);
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
380 if (p > nick)
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
381 *p = 0;
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
382 }
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
383 return nick;
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
384 }
b57a01ffeed6 Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents: 967
diff changeset
385
1065
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
386
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
387 /* PGP settings */
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
388
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
389 // settings_pgp_setdisabled(jid, value)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
390 // Enable/disable PGP encryption for jid.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
391 // (Set value to TRUE to disable encryption)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
392 void settings_pgp_setdisabled(const char *bjid, guint value)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
393 {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
394 #ifdef HAVE_GPGME
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
395 T_pgpopt *pgpdata;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
396 pgpdata = g_hash_table_lookup(pgpopt, bjid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
397 if (!pgpdata) {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
398 // If value is 0, we do not need to create a structure (that's
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
399 // the default value).
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
400 if (value) {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
401 pgpdata = g_new0(T_pgpopt, 1);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
402 pgpdata->pgp_disabled = value;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
403 g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
404 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
405 } else {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
406 pgpdata->pgp_disabled = value;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
407 // We could remove the key/value if pgp_disabled is 0 and
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
408 // pgp_keyid is NULL, actually.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
409 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
410 #endif
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
411 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
412
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
413 // settings_pgp_getdisabled(jid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
414 // Return TRUE if PGP encryption should be disabled for jid.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
415 guint settings_pgp_getdisabled(const char *bjid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
416 {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
417 #ifdef HAVE_GPGME
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
418 T_pgpopt *pgpdata;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
419 pgpdata = g_hash_table_lookup(pgpopt, bjid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
420 if (pgpdata)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
421 return pgpdata->pgp_disabled;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
422 else
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
423 return FALSE; // default: not disabled
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
424 #else
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
425 return TRUE; // No PGP support, let's say it's disabled.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
426 #endif
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
427 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
428
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
429 // settings_pgp_setkeyid(jid, keyid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
430 // Set the PGP KeyId for user jid.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
431 // Use keyid = NULL to erase the previous KeyId.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
432 void settings_pgp_setkeyid(const char *bjid, const char *keyid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
433 {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
434 #ifdef HAVE_GPGME
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
435 T_pgpopt *pgpdata;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
436 pgpdata = g_hash_table_lookup(pgpopt, bjid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
437 if (!pgpdata) {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
438 // If keyid is NULL, we do not need to create a structure (that's
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
439 // the default value).
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
440 if (keyid) {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
441 pgpdata = g_new0(T_pgpopt, 1);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
442 pgpdata->pgp_keyid = g_strdup(keyid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
443 g_hash_table_insert(pgpopt, g_strdup(bjid), pgpdata);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
444 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
445 } else {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
446 g_free(pgpdata->pgp_keyid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
447 if (keyid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
448 pgpdata->pgp_keyid = g_strdup(keyid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
449 else
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
450 pgpdata->pgp_keyid = NULL;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
451 // We could remove the key/value if pgp_disabled is 0 and
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
452 // pgp_keyid is NULL, actually.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
453 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
454 #endif
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
455 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
456
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
457 // settings_pgp_getkeyid(jid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
458 // Get the PGP KeyId for user jid.
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
459 const char *settings_pgp_getkeyid(const char *bjid)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
460 {
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
461 #ifdef HAVE_GPGME
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
462 T_pgpopt *pgpdata;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
463 pgpdata = g_hash_table_lookup(pgpopt, bjid);
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
464 if (pgpdata)
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
465 return pgpdata->pgp_keyid;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
466 #endif
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
467 return NULL;
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
468 }
230dca34dbea Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
469
580
fed6d1e4d7a9 Fix modelines
Mikael Berthe <mikael@lilotux.net>
parents: 576
diff changeset
470 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */