Use purple configuration directory for storing telegram state files
This commit is contained in:
parent
489535fbd4
commit
cd8085ce5a
2 changed files with 8 additions and 14 deletions
|
@ -74,7 +74,7 @@
|
|||
|
||||
PurplePlugin *_telegram_protocol = NULL;
|
||||
PurpleGroup *tggroup;
|
||||
const char *config_dir = ".telegram-purple";
|
||||
const char *config_dir = "telegram-purple";
|
||||
const char *pk_path = "/etc/telegram-purple/server.pub";
|
||||
|
||||
void on_user_get_info (struct tgl_state *TLS, void *info_data, int success, struct tgl_user *U);
|
||||
|
@ -782,26 +782,19 @@ static GList *tgprpl_chat_join_info (PurpleConnection * gc) {
|
|||
|
||||
static void tgprpl_login (PurpleAccount * acct) {
|
||||
debug ("tgprpl_login()");
|
||||
struct tgl_state *TLS = tgl_state_alloc ();
|
||||
PurpleConnection *gc = purple_account_get_connection (acct);
|
||||
char const *username = purple_account_get_username (acct);
|
||||
|
||||
struct tgl_state *TLS = tgl_state_alloc ();
|
||||
|
||||
const char *dir = config_dir;
|
||||
struct passwd *pw = getpwuid (getuid ());
|
||||
size_t len = strlen (dir) + strlen (pw->pw_dir) + 2 + strlen (username);
|
||||
TLS->base_path = malloc (len);
|
||||
snprintf (TLS->base_path, len, "%s/%s/%s", pw->pw_dir, dir, username);
|
||||
debug ("base configuration path: '%s'", TLS->base_path);
|
||||
g_mkdir_with_parents (TLS->base_path, 0700);
|
||||
|
||||
len += strlen ("/downloads");
|
||||
char *ddir = malloc (len);
|
||||
sprintf (ddir, "%s/downloads", TLS->base_path);
|
||||
TLS->base_path = g_strdup_printf ("%s/%s/%s", purple_user_dir(), config_dir, username);
|
||||
char *ddir = g_strdup_printf ("%s/%s", TLS->base_path, "downloads");
|
||||
tgl_set_download_directory (TLS, ddir);
|
||||
g_mkdir_with_parents (TLS->base_path, 0700);
|
||||
g_mkdir_with_parents (ddir, 0700);
|
||||
free (ddir);
|
||||
|
||||
debug ("base configuration path: '%s'", TLS->base_path);
|
||||
|
||||
tgl_set_verbosity (TLS, 4);
|
||||
tgl_set_rsa_key (TLS, pk_path);
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ void *connection_data_free (connection_data *conn) {
|
|||
tgp_g_list_free_full (conn->used_images, used_image_free);
|
||||
tgprpl_xfer_free_all (conn);
|
||||
tgl_free_all (conn->TLS);
|
||||
g_free(conn->TLS->base_path);
|
||||
free (conn->TLS);
|
||||
|
||||
free (conn);
|
||||
|
|
Loading…
Add table
Reference in a new issue