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");
}
示例#2
0
static void
create_sync_rpc_clients (const char *central_config_dir, const char *config_dir)
{
    CcnetClient *sync_client;

    /* sync client and rpc client */
    sync_client = ccnet_client_new ();
    if ( (ccnet_client_load_confdir(sync_client, central_config_dir, 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");
    ccnetrpc_client_t = ccnet_create_rpc_client (sync_client,
                                                 NULL,
                                                 "ccnet-threaded-rpcserver");
}
示例#3
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;
}
示例#4
0
文件: seafile.c 项目: 2bj/seafile
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 ;
}