diff --git a/purple-plugin/telegram-purple.c b/purple-plugin/telegram-purple.c index 0b2dab6..8abbf3e 100644 --- a/purple-plugin/telegram-purple.c +++ b/purple-plugin/telegram-purple.c @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include // Libpurple Plugin Includes #include "notify.h" @@ -331,7 +334,7 @@ void tgprpl_login_on_connected(gpointer *data, gint fd, const gchar *error_messa } struct telegram_config tgconf = { - "/home/dev-jessie/.telegram", + NULL, NULL, // on output telegram_on_proxy_request, telegram_on_proxy_close, @@ -343,8 +346,7 @@ struct telegram_config tgconf = { message_allocated_handler, peer_allocated_handler, on_new_user_status, - on_user_typing, - NULL + on_user_typing }; @@ -939,6 +941,15 @@ static PurplePluginProtocolInfo prpl_info = { static void tgprpl_init(PurplePlugin *plugin) { + const char *dir = ".telegram"; + if (!tgconf.base_config_path) { + struct passwd *pw = getpwuid(getuid()); + int len = strlen (dir) + strlen (pw->pw_dir) + 2; + tgconf.base_config_path = talloc (len); + tsnprintf (tgconf.base_config_path, len, "%s/%s", pw->pw_dir, dir); + logprintf ("base configuration path: %s", tgconf.base_config_path); + } + PurpleAccountOption *option; PurpleAccountUserSplit *split; GList *verification_values = NULL; diff --git a/telegram.h b/telegram.h index 14ea7eb..0a3bfb1 100644 --- a/telegram.h +++ b/telegram.h @@ -105,7 +105,7 @@ struct telegram_config { /** * The base path containing the telegram configuration */ - const char* base_config_path; + char* base_config_path; /** * Called when there is pending network output