updated on Tue Jan 10 08:08:34 UTC 2012
[aur-mirror.git] / midori-passwordmanager / lpins.c
blob1ffd998c386e71f4cb0b0bafaf23ea33ea380dd2
1 /*
2 Copyright (C) 2011 Giuseppe Borzi <gborzi@ieee.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 */
11 #include <gnome-keyring.h>
13 gchar* cleanurl( const gchar *url )
15 gchar *cleaned, *id;
16 gssize il = -1;
17 gsize lprt;
18 if ( ( id = g_strstr_len(url + 8,il,"/") ) != NULL )
20 lprt = id - url;
21 cleaned = g_strndup(url,lprt);
23 else
24 cleaned = g_strdup(url);
25 return cleaned;
28 int main( int argc, char **argv ) {
30 if ( argc < 4 ) {
31 g_print("Usage: %s url user password\n",argv[0]);
32 return 1;
35 if ( gnome_keyring_is_available() ) {
36 guint32 item_id; gchar *cleaned = cleanurl(argv[1]);
37 gnome_keyring_set_network_password_sync(NULL,
38 argv[2],
39 "midori",
40 cleaned,
41 NULL,
42 NULL,
43 NULL,
45 argv[3],
46 &item_id);
47 g_free(cleaned);
48 g_print("Created Gnome Keyring entry # %d\n",item_id);
49 } else {
50 g_print("Gnome Keyring not available!\n");
51 return 1;
53 return 0;