~remote-login-service-team/remote-login-service/trunk

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Ted Gould
  • Author(s): Albert Astals Cid
  • Date: 2012-09-21 04:47:27 UTC
  • mfrom: (66.1.7 save_set_last_used)
  • Revision ID: ted@gould.cx-20120921044727-ovzx1ya0t83hemcn
Handle the SetLastUsedServer calls

The data is saved in a file that is encrypted with the password and whose name is the hash of the username to provide as much privacy/security possible

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "rdp-server.h"
34
34
#include "citrix-server.h"
35
35
#include "uccs-server.h"
 
36
#include "crypt.h"
36
37
 
37
38
gint server_list_to_array (GVariantBuilder * builder, GList * items);
38
39
 
317
318
        return TRUE;
318
319
}
319
320
 
 
321
/* Set a given server as last used */
 
322
static gboolean
 
323
handle_set_last_used_server (RemoteLogin * rl, GDBusMethodInvocation * invocation, gpointer user_data)
 
324
{
 
325
        GVariant * params = g_dbus_method_invocation_get_parameters(invocation);
 
326
 
 
327
        GVariant * child = NULL;
 
328
        const gchar * uccsUri = NULL;
 
329
        const gchar * serverUri = NULL;
 
330
 
 
331
        child = g_variant_get_child_value(params, 0);
 
332
        uccsUri = g_variant_get_string(child, NULL);
 
333
        g_variant_unref(child); /* fine as we know params is still ref'd */
 
334
        
 
335
        child = g_variant_get_child_value(params, 1);
 
336
        serverUri = g_variant_get_string(child, NULL);
 
337
        g_variant_unref(child); /* fine as we know params is still ref'd */
 
338
        
 
339
        GList * lserver = NULL;
 
340
        Server * server = NULL;
 
341
        for (lserver = config_file_servers; lserver != NULL; lserver = g_list_next(lserver)) {
 
342
                server = SERVER(lserver->data);
 
343
 
 
344
                if (server == NULL) {
 
345
                        continue;
 
346
                }
 
347
 
 
348
                if (!IS_UCCS_SERVER(server)) {
 
349
                        continue;
 
350
                }
 
351
 
 
352
                if (g_strcmp0(server->uri, uccsUri) == 0) {
 
353
                        break;
 
354
                }
 
355
        }
 
356
        
 
357
        if (server != NULL) {
 
358
                server_set_last_used_server (server, serverUri);
 
359
        }
 
360
        
 
361
        g_dbus_method_invocation_return_value(invocation, NULL);
 
362
        
 
363
        return TRUE;
 
364
}
 
365
 
320
366
/* If we loose the name, tell the world and there's not much we can do */
321
367
static void
322
368
name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data)
382
428
        g_signal_connect(skel, "handle-get-servers", G_CALLBACK(handle_get_servers), NULL);
383
429
        g_signal_connect(skel, "handle-get-servers-for-login", G_CALLBACK(handle_get_servers_login), NULL);
384
430
        g_signal_connect(skel, "handle-get-cached-domains-for-server", G_CALLBACK(handle_get_domains), NULL);
 
431
        g_signal_connect(skel, "handle-set-last-used-server", G_CALLBACK(handle_set_last_used_server), NULL);
385
432
 
386
433
        g_bus_own_name_on_connection(session_bus,
387
434
                                     "com.canonical.RemoteLogin",