Пример #1
0
/* Ask ccnet daemon to quit, and disconnect client from daemon. */
void
stop_ccnet (void)
{
    CcnetClient *client = applet->client;
    CcnetClient *sync_client = applet->sync_client;
    
    if (!client)
        return;

    if (client->connected) {
        stop_mq_client ();
        
        send_command ("shutdown");
        ccnet_client_disconnect_daemon (client);
        if (sync_client && sync_client->connected)
            ccnet_client_disconnect_daemon (sync_client);

        trayicon_rotate (FALSE);

        rm_client_fd_from_mainloop ();
    }

    if (applet->heartbeat_monitor_on)
        stop_heartbeat_monitor ();

    trayicon_set_ccnet_state (CCNET_STATE_DOWN);
}
Пример #2
0
void 
on_ccnet_daemon_down (void)
{
    applet_warning ("Connection to daemon is down.\n");
    trayicon_rotate (FALSE);
    trayicon_set_ccnet_state (CCNET_STATE_DOWN);
    
    if (applet->client->connected) {
        ccnet_client_disconnect_daemon (applet->client);
        if (applet->sync_client->connected)
            ccnet_client_disconnect_daemon (applet->sync_client);
    }
}
Пример #3
0
static void
disconnect_clients ()
{
    CcnetClient *client, *sync_client;
    client = ctl->client;
    sync_client = ctl->sync_client;

    if (client->connected) {
        ccnet_client_disconnect_daemon (client);
    }

    if (sync_client->connected) {
        ccnet_client_disconnect_daemon (sync_client);
    }
}
Пример #4
0
static void read_cb (int fd, short event, void *vclient)
{
    CcnetClient *client = vclient;

    if (ccnet_client_read_input (client) <= 0) {
        ccnet_client_disconnect_daemon (client);
        exit (1);
    }
}
Пример #5
0
int main (int argc, char *argv[])
{
	struct cmd *c;

#if !GLIB_CHECK_VERSION(2, 35, 0)
    g_type_init();
#endif
	config_dir = DEFAULT_CONFIG_DIR;

    if (argc == 1) {
        usage();
        exit(1);
    }

    GError *error = NULL;
    GOptionContext *context;

    context = g_option_context_new (NULL);
    g_option_context_add_main_entries (context, entries, "seafile");
    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_print ("option parsing failed: %s\n", error->message);
        exit (1);
    }

    if (print_version) {
        show_version();
        exit(1);
    }

    if (argc <= 1) {
        usage();
        exit(1);
    }

    c = getcmd (argv[1]);
    if (c == NULL) {
        usage();
        exit(1);
    }

    client = ccnet_client_new ();
    if ( (ccnet_client_load_confdir(client, config_dir)) < 0 ) {
        fprintf (stderr, "Read config dir error\n");
        exit(1);
    }

	if (ccnet_client_connect_daemon(client, CCNET_CLIENT_SYNC) < 0)
    {
        fprintf(stderr, "Connect to server fail: %s\n", strerror(errno));
        exit(1);
    }

    rpc_client = ccnet_create_rpc_client (client, NULL, "seafserv-rpcserver");
    threaded_rpc_client = ccnet_create_rpc_client (client, NULL,
                                                   "seafserv-threaded-rpcserver");

    argc -= 2;
    argv += 2;
    c->handler (argc, argv);
	
	ccnet_client_disconnect_daemon (client);

	return 0;
}
Пример #6
0
int main (int argc, char *argv[])
{
	struct cmd *c;

    g_type_init ();
	config_dir = DEFAULT_CONFIG_DIR;

    if (argc == 1) {
        usage();
        exit(1);
    }

    GError *error = NULL;
    GOptionContext *context;

    context = g_option_context_new (NULL);
    g_option_context_add_main_entries (context, entries, "seafile");
    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_print ("option parsing failed: %s\n", error->message);
        exit (1);
    }

    if (print_version) {
        show_version();
        exit(1);
    }

    if (argc <= 1) {
        usage();
        exit(1);
    }

    c = getcmd (argv[1]);
    if (c == NULL) {
        usage();
        exit(1);
    }

    client = ccnet_client_new ();
    if ( (ccnet_client_load_confdir(client, central_config_dir, config_dir)) < 0 ) {
        fprintf (stderr, "Read config dir error\n");
        exit(1);
    }

    if (ccnet_client_connect_daemon(client, CCNET_CLIENT_SYNC) < 0)
    {
        fprintf(stderr, "Connect to server fail: %s\n", strerror(errno));
        exit(1);
    }

    priv.session = client;
    priv.peer_id = NULL;
    priv.service = "monitor";

    rpc_client = searpc_client_new ();
    rpc_client->transport = searpc_transport_send;
    rpc_client->arg = &priv;

    argc -= 2;
    argv += 2;
    c->handler (argc, argv);
	
	ccnet_client_disconnect_daemon (client);

	return 0;
}
Пример #7
0
int main (int argc, char *argv[])
{
    struct cmd *c;

    g_type_init ();
    config_dir = DEFAULT_CONFIG_DIR;

    if (argc == 1) {
        usage();
        exit(1);
    }

    int i = 0;

    /* first convert command line args to utf8 */
    for (i = 1; i < argc; i++) {
        argv[i] = ccnet_locale_to_utf8 (argv[i]);
        if (!argv[i])
            return -1;
    }

    GError *error = NULL;
    GOptionContext *context;

    context = g_option_context_new (NULL);
    g_option_context_add_main_entries (context, entries, "seafile");
    /* pass remaining options to handlers   */
    g_option_context_set_ignore_unknown_options (context, TRUE);
    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_print ("option parsing failed: %s\n", error->message);
        exit (1);
    }

    if (print_version) {
        show_version();
        exit(1);
    }

    if (argc <= 1) {
        usage();
        exit(1);
    }

    c = getcmd (argv[1]);
    if (c == NULL) {
        usage();
        exit(1);
    }

    g_log_set_default_handler (seafile_log, NULL);

    client = ccnet_client_new ();
    if ( (ccnet_client_load_confdir(client, config_dir)) < 0 ) {
        fprintf (stderr, "Read config dir error\n");
        exit(1);
    }

    if (ccnet_client_connect_daemon (client, CCNET_CLIENT_SYNC) < 0)
    {
        fprintf(stderr, "Connect to server fail: %s\n", strerror(errno));
        exit(1);
    }


    rpc_client = ccnet_create_rpc_client (client, NULL, "seafile-rpcserver");
    threaded_rpc_client = ccnet_create_rpc_client (client, NULL,
                                                   "seafile-threaded-rpcserver");

    argc -= 1;
    argv += 1;
    int ret = c->handler (argc, argv);

    ccnet_client_disconnect_daemon (client);

	return ret ;
}
Пример #8
0
int main(int argc, char *argv[])
{
    struct cmd *c;

#if !GLIB_CHECK_VERSION(2, 36, 0)
    g_type_init ();
#endif

    config_dir = DEFAULT_CONFIG_DIR;

    if (argc == 1) {
        usage();
        exit(1);
    }

    GError *error = NULL;
    GOptionContext *context;

    context = g_option_context_new (NULL);
    g_option_context_add_main_entries (context, entries, NULL);
    g_option_context_set_ignore_unknown_options (context, TRUE);
    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_print ("option parsing failed: %s\n", error->message);
        exit (1);
    }

    if (print_version) {
        show_version();
        exit(0);
    }

    if (argc <= 1) {
        usage();
        exit(1);
    }

    c = getcmd (argv[1]);
    if (c == NULL) {
        usage();
        exit(1);
    }
    
    g_log_set_default_handler (ccnet_servtool_log, NULL);

    client = ccnet_client_new ();
    if ( (ccnet_client_load_confdir(client, central_config_dir, config_dir)) < 0 ) {
        fprintf (stderr, "Read config dir error\n");
        exit(1);
    }

    if (ccnet_client_connect_daemon (client, CCNET_CLIENT_SYNC) < 0)
    {
        fprintf(stderr, "Connect to server fail: %s\n", strerror(errno));
        exit(1);
    }

    argc -= 2;
    argv += 2;
    c->handler (argc, argv);

    ccnet_client_disconnect_daemon (client);

    return 0;
}