updated on Fri Jan 13 20:02:10 UTC 2012
[aur-mirror.git] / mcabber-module-openurl / openurl.c
blob2a3b6849d85b99be5bb51518f1f989e2eaecb03e
1 #include <glib.h>
2 #include <gmodule.h>
3 #include <stdbool.h>
5 #include <sys/types.h>
7 #include <commands.h>
8 #include <logprint.h>
9 #include <roster.h>
10 #include <settings.h>
12 static void do_open(char *arg)
14 const char* logging_dir = settings_opt_get("logging_dir");
15 if(!logging_dir)
17 scr_LogPrint(LPRINT_NORMAL,
18 "Logging dir is not set.");
20 else if(current_buddy)
22 const char* bjid = CURRENT_JID;
23 if(bjid)
25 char command[2048];
26 bool number = false;
27 if(isdigit(*arg) || !*arg)
29 number = true;
31 sprintf(command,"~/.mcabber/openlink %s%s %s %s >/dev/null 2>&1", logging_dir, bjid, number ? "number" : "nan", arg);
32 system(command);
34 else
36 scr_LogPrint(LPRINT_NORMAL,
37 "Please select a buddy.");
40 else
42 scr_LogPrint(LPRINT_NORMAL,
43 "Please select a buddy.");
49 /* Register command */
50 const gchar* g_module_check_init (GModule *module)
52 cmd_add ("open", "", 0, 0, do_open, NULL);
53 return NULL;
56 /* Unregister command */
57 void g_module_unload (GModule *module)
59 cmd_del ("open");