void SeafileRpcClient::connectDaemon() { sync_client_ = ccnet_client_new(); sync_client_for_threaded_rpc_ = ccnet_client_new(); const QString config_dir = seafApplet->configurator()->ccnetDir(); if (ccnet_client_load_confdir(sync_client_, NULL, toCStr(config_dir)) < 0) { seafApplet->errorAndExit(tr("failed to load ccnet config dir %1").arg(config_dir)); } if (ccnet_client_connect_daemon(sync_client_, CCNET_CLIENT_SYNC) < 0) { return; } ccnet_client_load_confdir(sync_client_for_threaded_rpc_, NULL, toCStr(config_dir)); ccnet_client_connect_daemon(sync_client_for_threaded_rpc_, CCNET_CLIENT_SYNC); seafile_rpc_client_ = ccnet_create_rpc_client(sync_client_, NULL, kSeafileRpcService); ccnet_rpc_client_ = ccnet_create_rpc_client(sync_client_, NULL, kCcnetRpcService); seafile_threaded_rpc_client_ = ccnet_create_rpc_client( sync_client_for_threaded_rpc_, NULL, kSeafileThreadedRpcService); qWarning("[Rpc Client] connected to daemon"); }
static gboolean do_connect_ccnet () { CcnetClient *client, *sync_client; client = ctl->client; sync_client = ctl->sync_client; if (!client->connected) { if (ccnet_client_connect_daemon (client, CCNET_CLIENT_ASYNC) < 0) { return TRUE; } } if (!sync_client->connected) { if (ccnet_client_connect_daemon (sync_client, CCNET_CLIENT_SYNC) < 0) { return TRUE; } } seaf_message ("ccnet daemon connected.\n"); on_ccnet_connected (); return FALSE; }
void MessageListener::connectDaemon() { async_client_ = ccnet_client_new(); sync_client_ = ccnet_client_new(); const QString config_dir = seafApplet->configurator()->ccnetDir(); const QByteArray path = config_dir.toUtf8(); if (ccnet_client_load_confdir(async_client_, path.data()) < 0) { seafApplet->errorAndExit(tr("failed to load ccnet config dir ").append(config_dir)); } if (ccnet_client_connect_daemon(async_client_, CCNET_CLIENT_ASYNC) < 0) { return; } if (ccnet_client_load_confdir(sync_client_, path.data()) < 0) { seafApplet->errorAndExit(tr("failed to load ccnet config dir ").append(config_dir)); } if (ccnet_client_connect_daemon(sync_client_, CCNET_CLIENT_SYNC) < 0) { return; } socket_notifier_ = new QSocketNotifier(async_client_->connfd, QSocketNotifier::Read); connect(socket_notifier_, SIGNAL(activated(int)), this, SLOT(readConnfd())); qWarning("[MessageListener] connected to daemon"); startMqClient(); }
int connect_to_daemon (void) { applet_message ("connecting ccnet ...\n"); CcnetClient *client = applet->client; CcnetClient *sync_client = applet->sync_client; if (client->connected && sync_client->connected) { return 0; } if (!client->connected) { if (ccnet_client_connect_daemon (client, CCNET_CLIENT_ASYNC) < 0) { applet_warning("connect to ccnet daemon fail: %s\n", strerror(errno)); trayicon_set_ccnet_state (CCNET_STATE_DOWN); return -1; } } if (!sync_client->connected) { if (ccnet_client_connect_daemon (sync_client, CCNET_CLIENT_SYNC) < 0) { applet_warning ("sync_client: connect to ccnet daemon failed: %s\n", strerror(errno)); applet_exit(1); } } trayicon_set_ccnet_state (CCNET_STATE_UP); add_client_fd_to_mainloop (); applet_init_ccnet_rpc (sync_client); applet_init_seafile_rpc (client); applet_start_rpc_service(client); start_mq_client (); return 0; }
void DaemonManager::tryConnCcnet() { qDebug("trying to connect to ccnet daemon...\n"); if (ccnet_client_connect_daemon(sync_client_, CCNET_CLIENT_SYNC) < 0) { return; } else { conn_daemon_timer_->stop(); qDebug("connected to ccnet daemon\n"); startSeafileDaemon(); } }
bool OpenLocalHelper::connectToCcnetDaemon() { sync_client_ = ccnet_client_new(); const QString ccnet_dir = defaultCcnetDir(); if (ccnet_client_load_confdir(sync_client_, toCStr(ccnet_dir)) < 0) { g_object_unref (sync_client_); sync_client_ = NULL; return false; } if (ccnet_client_connect_daemon(sync_client_, CCNET_CLIENT_SYNC) < 0) { g_object_unref (sync_client_); sync_client_ = NULL; return false; } return true; }
static CcnetClient * create_new_client (const char *conf_dir) { CcnetClient *client; client = ccnet_client_new (); if (ccnet_client_load_confdir (client, conf_dir) < 0) { g_warning ("[Sea RPC] Failed to load conf dir.\n"); g_object_unref (client); return NULL; } if (ccnet_client_connect_daemon (client, CCNET_CLIENT_SYNC) < 0) { g_warning ("[Sea RPC] Failed to connect ccnet.\n"); g_object_unref (client); return NULL; } return client; }
static void create_sync_rpc_clients (const char *config_dir) { CcnetClient *sync_client; /* sync client and rpc client */ sync_client = ccnet_client_new (); if ( (ccnet_client_load_confdir(sync_client, config_dir)) < 0 ) { seaf_warning ("Read config dir error\n"); exit(1); } if (ccnet_client_connect_daemon (sync_client, CCNET_CLIENT_SYNC) < 0) { seaf_warning ("Connect to server fail: %s\n", strerror(errno)); exit(1); } ccnetrpc_client = ccnet_create_rpc_client (sync_client, NULL, "ccnet-rpcserver"); }
void do_stop() { CcnetClient *sync_client = ccnet_client_new(); const QString ccnet_dir = defaultCcnetDir(); if (ccnet_client_load_confdir(sync_client, NULL, toCStr(ccnet_dir)) < 0) { return; } if (ccnet_client_connect_daemon(sync_client, CCNET_CLIENT_SYNC) < 0) { return; } CcnetMessage *quit_message; quit_message = ccnet_message_new (sync_client->base.id, sync_client->base.id, kAppletCommandsMQ, "quit", 0); ccnet_client_send_message(sync_client, quit_message); ccnet_message_free(quit_message); g_object_unref (sync_client); }
/** * Inititialize ccnet client structure, connect daemon and initialize * event loop. */ CcnetClient * ccnet_init (const char *confdir) { CcnetClient *client; client = ccnet_client_new (); if ( (ccnet_client_load_confdir(client, confdir)) < 0 ) { ccnet_warning ("Read config dir error\n"); return NULL; } if (ccnet_client_connect_daemon (client, CCNET_CLIENT_ASYNC) < 0) { ccnet_warning ("Connect to ccnet daemon error\n"); exit(1); } ccnet_client_run_synchronizer (client); event_init (); return client; }
/* * Bind to an unused service to make sure only one instance of seaf-daemon * is running. */ static gboolean bind_ccnet_service (const char *config_dir) { gboolean ret = TRUE; bind_client = ccnet_client_new (); if ( (ccnet_client_load_confdir(bind_client, config_dir)) < 0 ) { seaf_warning ("Read config dir error\n"); exit(1); } if (ccnet_client_connect_daemon (bind_client, CCNET_CLIENT_SYNC) < 0) { seaf_warning ("Connect to server fail: %s\n", strerror(errno)); exit(1); } if (!ccnet_register_service_sync (bind_client, "seafile-dummy-service", "rpc-inner")) ret = FALSE; return ret; }
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; }
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; }
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 ; }
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; }