Jabber WindowGram Client (JWGC)

Introduction Screenshots Installation Downloads
Documentation Browse Source Resources Project Site

Stable Version
-none-

Latest Version
beta5



Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

jwgc_variables.c

Go to the documentation of this file.
00001 #include "main.h"
00002 #include <libjwgc.h>
00003 
00004 int
00005 jwgc_show_password_event_handler()
00006 {
00007         jVars_set_error("Displaying password is not permitted.");
00008         return 0;
00009 }
00010 
00011 #define PRESENCE_AVAILABLE      "available"
00012 #define PRESENCE_NORMAL         "normal"
00013 #define PRESENCE_AWAY           "away"
00014 #define PRESENCE_XA             "xa"
00015 #define PRESENCE_DND            "dnd"
00016 #define PRESENCE_CHAT           "chat"
00017 
00018 int
00019 jwgc_check_presence_event_handler(setting)
00020         char *setting;
00021 {
00022         if (!strcasecmp(setting, PRESENCE_AVAILABLE))
00023                 return 1;
00024         else if (!strcasecmp(setting, PRESENCE_NORMAL))
00025                 return 1;
00026         else if (!strcasecmp(setting, PRESENCE_AWAY))
00027                 return 1;
00028         else if (!strcasecmp(setting, PRESENCE_XA))
00029                 return 1;
00030         else if (!strcasecmp(setting, PRESENCE_DND))
00031                 return 1;
00032         else if (!strcasecmp(setting, PRESENCE_CHAT))
00033                 return 1;
00034         else {
00035                 jVars_set_error("The presence setting must be one of:\n\
00036 PRESENCE_AVAILABLE, PRESENCE_NORMAL, PRESENCE_AWAY, PRESENCE_XA, PRESENCE_DND, PRESENCE_CHAT.");
00037                 return 0;                             
00038         }
00039 }
00040 
00041 void
00042 jwgc_change_presence_event_handler(oldval, newval)
00043         char *oldval;
00044         char *newval;
00045 {
00046         xode out, x, y;
00047 
00048         dprintf(dExecution, "Old presence = %s, New = %s\n", oldval, newval);
00049         if (newval && (!oldval || strcmp(oldval, newval))) {
00050                 if (jab_c) {
00051                         dprintf(dExecution, "Setting presence to %s\n", newval);
00052                         if (strcmp(newval, "available")) {
00053                                 out = jabutil_presnew(JABPACKET__AVAILABLE,
00054                                         NULL,
00055                                         newval,
00056                                         *(int *)jVars_get(jVarPriority));
00057                                 x = xode_insert_tag(out, "show");
00058                                 y = xode_insert_cdata(x, oldval,
00059                                                   strlen(oldval));
00060                         }
00061                         else {
00062                                 out = jabutil_presnew(JABPACKET__AVAILABLE,
00063                                         NULL,
00064                                         NULL,
00065                                         *(int *)jVars_get(jVarPriority));
00066                         }
00067                         jab_send(jab_c, out);
00068                         xode_free(out);
00069                 }
00070         }
00071 }
00072 
00073 void
00074 jwgc_change_resource_event_handler(oldval, newval)
00075         char *oldval;
00076         char *newval;
00077 {
00078         if (!newval) { return; }
00079 
00080         if (!strncmp(newval, "HOSTNAME", 8)) {
00081                 char hostname[1024];
00082                 if (!gethostname(hostname, sizeof(hostname))) {
00083                         hostname[1023] = '\0'; /* paranoia */
00084                         if (!strncmp(newval, "HOSTNAMETRIMMED", 15)) {
00085                                 char *pos;
00086                                 pos = strchr(hostname, '.');
00087                                 if (pos) {
00088                                         *pos = '\0';
00089                                 }
00090                         }
00091                         jVars_set(jVarResource, hostname);
00092                 }
00093         }
00094 }
00095 
00096 void setup_jwgc_variable_handlers()
00097 {
00098         jVars_set_show_handler(jVarPassword, jwgc_show_password_event_handler);
00099         jVars_set_change_handler(jVarPresence, jwgc_change_presence_event_handler);
00100         jVars_set_change_handler(jVarResource, jwgc_change_resource_event_handler);
00101         jVars_set_check_handler(jVarPresence, jwgc_check_presence_event_handler);
00102 }
00103 
00104 void
00105 jwg_set_defaults_handler()
00106 {
00107         jVars_set(jVarPresence, DEFPRESENCE);
00108         jVars_set(jVarPriority, DEFPRIORITY);
00109         jVars_set(jVarServer, DEFSERVER);
00110         jVars_set(jVarResource, DEFRESOURCE);
00111         jVars_set(jVarPort, DEFPORT);
00112 #ifdef USE_SSL
00113         jVars_set(jVarUseSSL, DEFUSESSL);
00114 #endif /* USE_SSL */
00115 #ifdef USE_GPGME
00116         jVars_set(jVarUseGPG, DEFUSEGPG);
00117 #endif /* USE_GPGME */
00118 
00119         setup_jwgc_variable_handlers();
00120 }


Last updated at Tue Dec 18 21:07:42 PST 2007. This site and project hosted by...SourceForge.net Logo
Source Perspective by Fisheye