summary refs log tree commit diff stats
path: root/plugins
diff options
context:
space:
mode:
authorBerke Viktor <berkeviktor@aol.com>2012-01-10 05:22:58 +0100
committerBerke Viktor <berkeviktor@aol.com>2012-01-10 05:22:58 +0100
commit1cbe3789da4a3684db9de79f6bfd98ff3de3c5ff (patch)
tree240c1884661911b4e03150482128d3fa2fcb874f /plugins
parent66d8b0ad7b849ed743d3c3b4199fd05ece3891bb (diff)
xsasl save/load more or less works, need to get rid of lists
Diffstat (limited to 'plugins')
-rw-r--r--plugins/xsasl/xsasl.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/plugins/xsasl/xsasl.c b/plugins/xsasl/xsasl.c
index 776b8137..4b1e06b3 100644
--- a/plugins/xsasl/xsasl.c
+++ b/plugins/xsasl/xsasl.c
@@ -20,7 +20,7 @@
 
 #define PNAME "XSASL"
 #define PDESC "SASL authentication plugin";
-#define PVERSION "0.0.4"
+#define PVERSION "1.0"
 
 static xchat_plugin *ph;   /* plugin handle */
 
@@ -40,6 +40,7 @@ sasl_info* all_info = NULL;
 
 static void add_info(char const* login, char const* password, char const* network)
 {
+  char buffer[512];
   sasl_info* prev = all_info;
   sasl_info* info = (sasl_info*)malloc(sizeof(sasl_info));
 
@@ -49,16 +50,43 @@ static void add_info(char const* login, char const* password, char const* networ
   info->next = prev;
 
   all_info = info;
+
+  sprintf (buffer, "%s:%s", login, password);
+  xchat_set_pluginpref_str (ph, network, buffer);
 }
 
 static sasl_info* find_info(char const* network)
 {
-  sasl_info* cur = all_info;
+  //sasl_info* cur;
+  sasl_info* cur = (sasl_info*)malloc(sizeof(sasl_info));
+  char buffer[512];
+  char* pos;
+  char* token;
+
+  // DEBUG
+  if (xchat_get_pluginpref_str (ph, network, buffer))
+  {
+    cur->network = strdup (network);
+	//pos = strchr (buffer, ':');
+	//cur->login = g_strndup (buffer, pos-buffer);
+	token = strtok (buffer, ":");
+	cur->login = g_strdup (token);
+	token = strtok (NULL, ":");
+	cur->password = g_strdup (token);
+	//xchat_printf (ph, "network: %s\n", cur->network);
+	//xchat_printf (ph, "login: %s\n", cur->login);
+	//xchat_printf (ph, "password: %s\n", cur->password);
+	cur->next = NULL;
+	return cur;
+  }
+#if 0
+  cur = all_info;
   while (cur)
   {
     if (0 == strcmp(cur->network, network)) return cur;
     cur = cur->next;
   }
+#endif
   return NULL;
 }
 
@@ -142,7 +170,7 @@ static int sasl_cmd_cb(char *word[], char *word_eol[], void *userdata)
     sasl_info *cur = all_info;
     if (NULL == cur)
     {
-      xchat_printf(ph,"Nothing, see /help sasl");
+      xchat_printf(ph,"Nothing, see /HELP XSASL");
       return XCHAT_EAT_ALL;
     }
 
@@ -156,7 +184,7 @@ static int sasl_cmd_cb(char *word[], char *word_eol[], void *userdata)
 
   if (!login || !password || !network || !*login || !*password || !*network)
   {
-    xchat_printf(ph,"Wrong usage, try /help sasl");
+    xchat_printf(ph,"Wrong usage, try /HELP XSASL");
     return XCHAT_EAT_ALL;
   }
 
@@ -192,7 +220,7 @@ int xchat_plugin_init(xchat_plugin *plugin_handle,
   *plugin_desc = PDESC;
   *plugin_version = PVERSION;
 
-  xchat_hook_command(ph, "sasl", XCHAT_PRI_NORM, sasl_cmd_cb, 
+  xchat_hook_command(ph, "xsasl", XCHAT_PRI_NORM, sasl_cmd_cb,
     "Usage: SASL <login> <password> <network>, enable SASL authentication for given network", 0);
 
   xchat_hook_print(ph, "Connected", XCHAT_PRI_NORM, connect_cb, NULL);