Mercurial > pidgin.yaz
comparison src/gaimrc.c @ 1137:5b5d03dfa48a
[gaim-migrate @ 1147]
Started setting up the new Buddy Pounce code.
The UI needs a little more work as it is a little cluttered right now.
The .gaimrc file is now in revision 4. It properly saves buddy pounces
between v3 and v4 and converts them.
Actual functionality will be commited soon. I remembered that I didnt commit
so I woke up to do so just incase :D
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Sun, 26 Nov 2000 10:45:49 +0000 |
parents | c73736fa0b7c |
children | ce935e673907 |
comparison
equal
deleted
inserted
replaced
1136:c8615d023aaf | 1137:5b5d03dfa48a |
---|---|
34 #include <gtk/gtk.h> | 34 #include <gtk/gtk.h> |
35 #include "gaim.h" | 35 #include "gaim.h" |
36 | 36 |
37 /* for people like myself, who are too lazy to add an away msg :) */ | 37 /* for people like myself, who are too lazy to add an away msg :) */ |
38 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" | 38 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" |
39 #define MAX_VALUES 7 | |
39 | 40 |
40 GList *aim_users = NULL; | 41 GList *aim_users = NULL; |
41 int general_options; | 42 int general_options; |
42 int display_options; | 43 int display_options; |
43 int sound_options; | 44 int sound_options; |
49 char latest_ver[25]; | 50 char latest_ver[25]; |
50 char *sound_file[NUM_SOUNDS]; | 51 char *sound_file[NUM_SOUNDS]; |
51 | 52 |
52 struct parse { | 53 struct parse { |
53 char option[256]; | 54 char option[256]; |
54 char value[6][256]; | 55 char value[MAX_VALUES][256]; |
55 }; | 56 }; |
56 | 57 |
57 static struct parse *parse_line(char *line) | 58 static struct parse *parse_line(char *line) |
58 { | 59 { |
59 char *c = line; | 60 char *c = line; |
60 int inopt = 1, inval = 0, curval = -1; | 61 int inopt = 1, inval = 0, curval = -1; |
61 int optlen = 0, vallen = 0; | 62 int optlen = 0, vallen = 0; |
62 static struct parse p; | 63 static struct parse p; |
63 | 64 int x; |
64 | 65 |
66 for (x = 0; x < MAX_VALUES; x++) { | |
67 p.value[x][0] = 0; | |
68 } | |
69 | |
70 | |
65 while(*c) { | 71 while(*c) { |
66 if (*c == '\t') { | 72 if (*c == '\t') { |
67 c++; | 73 c++; |
68 continue; | 74 continue; |
69 } | 75 } |
113 continue; | 119 continue; |
114 } | 120 } |
115 } | 121 } |
116 c++; | 122 c++; |
117 } | 123 } |
124 | |
118 return &p; | 125 return &p; |
119 } | 126 } |
120 | 127 |
121 | 128 |
122 static int gaimrc_parse_tag(FILE *f) | 129 static int gaimrc_parse_tag(FILE *f) |
275 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); | 282 g_snprintf(b->name, sizeof(b->name), "%s", p->value[0]); |
276 g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]); | 283 g_snprintf(b->message, sizeof(b->message), "%s", p->value[1]); |
277 | 284 |
278 b->popup = atoi(p->value[2]); | 285 b->popup = atoi(p->value[2]); |
279 b->sendim = atoi(p->value[3]); | 286 b->sendim = atoi(p->value[3]); |
280 | 287 |
288 /* Let's check our version and see what's going on here */ | |
289 if ((p->value[4]) && (strlen(p->value[4]) > 0)) | |
290 { | |
291 /* If we have data, lets use it */ | |
292 b->signon = atoi(p->value[4]); | |
293 b->unaway = atoi(p->value[5]); | |
294 b->unidle = atoi(p->value[6]); | |
295 } | |
296 else | |
297 { | |
298 /* Otherwise, we have old info. Let's adjust */ | |
299 b->signon = 1; | |
300 b->unaway = 0; | |
301 b->unidle = 0; | |
302 } | |
303 | |
281 filter_break(b->message); | 304 filter_break(b->message); |
282 buddy_pounces = g_list_append(buddy_pounces, b); | 305 buddy_pounces = g_list_append(buddy_pounces, b); |
283 } | 306 } |
284 } | 307 } |
285 } | 308 } |
293 | 316 |
294 if (pnc) | 317 if (pnc) |
295 { | 318 { |
296 while (pnc) { | 319 while (pnc) { |
297 char *str1, *str2; | 320 char *str1, *str2; |
298 int popup, sendim; | |
299 | 321 |
300 b = (struct buddy_pounce *)pnc->data; | 322 b = (struct buddy_pounce *)pnc->data; |
301 | 323 |
302 str1 = escape_text2(b->name); | 324 str1 = escape_text2(b->name); |
303 if (strlen(b->message)) | 325 if (strlen(b->message)) |
304 str2 = escape_text2(b->message); | 326 str2 = escape_text2(b->message); |
305 else { | 327 else { |
306 str2 = malloc(1); | 328 str2 = malloc(1); |
307 str2[0] = 0; | 329 str2[0] = 0; |
308 } | 330 } |
309 popup = b->popup; | 331 |
310 sendim = b->sendim; | 332 fprintf(f, "\tentry { %s } { %s } { %d } { %d } { %d } { %d } { %d }\n", str1, str2, b->popup, b->sendim, b->signon, b->unaway, b->unidle); |
311 | |
312 fprintf(f, "\tentry { %s } { %s } { %d } { %d }\n", str1, str2, popup, sendim); | |
313 | 333 |
314 /* escape_text2 uses malloc(), so we don't want to g_free these */ | 334 /* escape_text2 uses malloc(), so we don't want to g_free these */ |
315 free(str1); | 335 free(str1); |
316 free(str2); | 336 free(str2); |
317 | 337 |
839 } | 859 } |
840 | 860 |
841 if ( (ver == 2) || (buf[0] != '#')) { | 861 if ( (ver == 2) || (buf[0] != '#')) { |
842 set_defaults(TRUE); | 862 set_defaults(TRUE); |
843 } | 863 } |
844 | |
845 } | 864 } |
846 | 865 |
847 void save_prefs() | 866 void save_prefs() |
848 { | 867 { |
849 FILE *f; | 868 FILE *f; |
850 char buf[BUF_LONG]; | 869 char buf[BUF_LONG]; |
851 | 870 |
852 if (getenv("HOME")) { | 871 if (getenv("HOME")) { |
853 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); | 872 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); |
854 if ((f = fopen(buf,"w"))) { | 873 if ((f = fopen(buf,"w"))) { |
855 fprintf(f, "# .gaimrc v%d\n", 3); | 874 fprintf(f, "# .gaimrc v%d\n", 4); |
856 gaimrc_write_users(f); | 875 gaimrc_write_users(f); |
857 gaimrc_write_options(f); | 876 gaimrc_write_options(f); |
858 gaimrc_write_sounds(f); | 877 gaimrc_write_sounds(f); |
859 gaimrc_write_away(f); | 878 gaimrc_write_away(f); |
860 #ifdef GAIM_PLUGINS | 879 #ifdef GAIM_PLUGINS |