main: Read config file only if no jid parameter provided
Signed-off-by: nex <nex@nexadn.de>
This commit is contained in:
parent
ecb5697ddb
commit
d1abb7ebc5
46
src/main.c
46
src/main.c
@ -413,30 +413,32 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading config file
|
// Loading config file if jid not provided by command line
|
||||||
GKeyFile *config_file = g_key_file_new();
|
if (jid == NULL) {
|
||||||
GError *error = NULL;
|
GKeyFile *config_file = g_key_file_new();
|
||||||
GString* configfile = g_string_new( g_get_home_dir());
|
GError *error = NULL;
|
||||||
g_string_append(configfile,"/.config/xmppc.conf");
|
GString* configfile = g_string_new( g_get_home_dir());
|
||||||
gboolean configfilefound = g_key_file_load_from_file(
|
g_string_append(configfile,"/.config/xmppc.conf");
|
||||||
config_file,
|
gboolean configfilefound = g_key_file_load_from_file(
|
||||||
configfile->str,
|
config_file,
|
||||||
G_KEY_FILE_NONE,
|
configfile->str,
|
||||||
&error);
|
G_KEY_FILE_NONE,
|
||||||
|
&error);
|
||||||
|
|
||||||
if (!configfilefound) {
|
if (!configfilefound) {
|
||||||
if(!g_error_matches(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
|
if(!g_error_matches(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
|
||||||
logError(&xmppc, "Error loading key file: %s", error->message);
|
logError(&xmppc, "Error loading key file: %s", error->message);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(jid == NULL && pwd == NULL) {
|
if(jid == NULL && pwd == NULL) {
|
||||||
logInfo(&xmppc,"Loading default account\n");
|
logInfo(&xmppc,"Loading default account\n");
|
||||||
if( account == NULL ) {
|
if( account == NULL ) {
|
||||||
account = "default";
|
account = "default";
|
||||||
|
}
|
||||||
|
jid = g_key_file_get_value (config_file, account, "jid" ,&error);
|
||||||
|
pwd = g_key_file_get_value (config_file, account, "pwd" ,&error);
|
||||||
}
|
}
|
||||||
jid = g_key_file_get_value (config_file, account, "jid" ,&error);
|
|
||||||
pwd = g_key_file_get_value (config_file, account, "pwd" ,&error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user