Beispiel #1
0
void
test_searpc__invalid_call (void)
{
    char *fcall, *fret;
    gsize fcall_len, ret_len;
    gchar* result;
    GError *error = NULL;

    result = searpc_client_call__string (client, "nonexist_func", &error,
                                         2, "string", "hello", "int", 2);
    cl_assert (error != NULL);
    g_free (result);
}
int SeafileRpcClient::ccnetGetConfig(const QString &key, QString *value)
{
    GError *error = NULL;
    char *ret = searpc_client_call__string (ccnet_rpc_client_,
                                            "get_config", &error,
                                            1, "string", toCStr(key));
    if (error) {
        g_error_free(error);
        return -1;
    }
    *value = QString::fromUtf8(ret);

    g_free (ret);
    return 0;
}
Beispiel #3
0
char *
seafile_post_multi_files (SearpcClient *client,
                          const char *repo_id,
                          const char *parent_dir,
                          const char *filenames_json,
                          const char *paths_json,
                          const char *user,
                          GError **error)
{
    return searpc_client_call__string (client, "seafile_post_multi_files", error,
                                       5, "string", repo_id,
                                       "string", parent_dir,
                                       "string", filenames_json,
                                       "string", paths_json,
                                       "string", user);
}
int SeafileRpcClient::seafileGetConfig(const QString &key, QString *value)
{
    GError *error = NULL;
    char *ret = searpc_client_call__string (seafile_rpc_client_,
                                            "seafile_get_config", &error,
                                            1, "string", toCStr(key));
    if (error) {
        qWarning("Unable to get config value %s", key.toUtf8().data());
        g_error_free(error);
        return -1;
    }
    *value = QString::fromUtf8(ret);

    g_free (ret);
    return 0;
}
Beispiel #5
0
char *
seafile_create_repo (SearpcClient *client,
                     const gchar *name, 
                     const gchar *description,
                     const gchar *worktree,
                     const gchar *passwd,
                     const gchar *relay_id,
                     int keep_local_history,
                     GError **error)
{
    g_return_val_if_fail (client && name && description && worktree, NULL);

    return searpc_client_call__string (
        client, "seafile_create_repo", error,
        6, "string", name, "string", description,
        "string", worktree, "string", passwd,
        "string", relay_id, "int", keep_local_history);
}
Beispiel #6
0
char *
seafile_put_file (SearpcClient *client,
                  const char *repo_id,
                  const char *file_path,
                  const char *parent_dir,
                  const char *file_name,
                  const char *user,
                  const char *head_id,
                  GError **error)
{
    return searpc_client_call__string (client, "seafile_put_file", error,
                                       6, "string", repo_id,
                                       "string", file_path,
                                       "string", parent_dir,
                                       "string", file_name,
                                       "string", user,
                                       "string", head_id);
}
int SeafileRpcClient::cloneRepo(const QString& id,
                                int repo_version, const QString& relayId,
                                const QString &name, const QString &wt,
                                const QString &token, const QString &passwd,
                                const QString &magic, const QString &peerAddr,
                                const QString &port, const QString &email,
                                const QString& random_key, int enc_version,
                                const QString& more_info,
                                QString *error_ret)
{
    GError *error = NULL;
    char *ret = searpc_client_call__string(
        seafile_rpc_client_,
        "seafile_clone",
        &error, 14,
        "string", toCStr(id),
        "int", repo_version,
        "string", toCStr(relayId),
        "string", toCStr(name),
        "string", toCStr(wt),
        "string", toCStr(token),
        "string", toCStr(passwd),
        "string", toCStr(magic),
        "string", toCStr(peerAddr),
        "string", toCStr(port),
        "string", toCStr(email),
        "string", toCStr(random_key),
        "int", enc_version,
        "string", toCStr(more_info));

    if (error != NULL) {
        if (error_ret) {
            // copy string
            *error_ret = error->message;
        }
        g_error_free(error);
        return -1;
    }

    g_free(ret);
    return 0;
}
int SeafileRpcClient::markFileLockState(const QString &repo_id,
                                        const QString &path_in_repo,
                                        bool lock)
{
    GError *error = NULL;
    char *ret = searpc_client_call__string (
        seafile_rpc_client_,
        lock ? "seafile_mark_file_locked" : "seafile_mark_file_unlocked",
        &error, 2,
        "string", toCStr(repo_id),
        "string", toCStr(path_in_repo));
    if (error) {
        qWarning("failed to mark file lock state: %s\n", error->message);
        g_error_free(error);
        return -1;
    }

    g_free (ret);
    return 0;
}
char *
seafile_post_file_blocks (SearpcClient *client,
                          const char *repo_id,
                          const char *parent_dir,
                          const char *file_name,
                          const char *blockids_json,
                          const char *paths_json,
                          const char *user,
                          gint64 file_size,
                          GError **error)
{
    return searpc_client_call__string (client, "seafile_post_file_blocks", error,
                                       7, "string", repo_id,
                                       "string", parent_dir,
                                       "string", file_name,
                                       "string", blockids_json,
                                       "string", paths_json,
                                       "string", user,
                                       "int64", &file_size);
}
int SeafileRpcClient::getRepoProperty(const QString &repo_id,
                                      const QString& name,
                                      QString *value)
{
    GError *error = NULL;
    char *ret = searpc_client_call__string (
        seafile_rpc_client_,
        "seafile_get_repo_property",
        &error, 2,
        "string", toCStr(repo_id),
        "string", toCStr(name)
        );
    if (error) {
        g_error_free(error);
        return -1;
    }
    *value = QString::fromUtf8(ret);

    g_free(ret);
    return 0;
}
Beispiel #11
0
int SeafileRpcClient::downloadRepo(const QString& id,
                                   int repo_version, const QString& relayId,
                                   const QString& name, const QString& wt,
                                   const QString& token, const QString& passwd,
                                   const QString& magic, const QString& peerAddr,
                                   const QString& port, const QString& email,
                                   const QString& random_key, int enc_version,
                                   QString *error_ret)
{
    GError *error = NULL;
    searpc_client_call__string(
        seafile_rpc_client_,
        "seafile_download",
        &error, 13,
        "string", toCStr(id),
        "int", repo_version,
        "string", toCStr(relayId),
        "string", toCStr(name),
        "string", toCStr(wt),
        "string", toCStr(token),
        "string", toCStr(passwd),
        "string", toCStr(magic),
        "string", toCStr(peerAddr),
        "string", toCStr(port),
        "string", toCStr(email),
        "string", toCStr(random_key),
        "int", enc_version);

    if (error != NULL) {
        if (error_ret) {
            *error_ret = error->message;
        }
        return -1;
    }

    return 0;
}
Beispiel #12
0
static void * do_pipe_connect_and_request(void *arg)
{
    SearpcClient *client = do_create_client_with_pipe_transport();

    // 100KB
    int size = 100 * 1024;
    GString *large_string = g_string_sized_new(size);
    while (large_string->len < size) {
        g_string_append(large_string, "aaaa");
    }

    gchar* result;
    GError *error = NULL;
    result = searpc_client_call__string (client, "get_substring", &error,
                                         2, "string", large_string->str, "int", 2);
    cl_assert_ (error == NULL, error ? error->message : "");
    cl_assert_ (strcmp(result, "aa") == 0, result);
    g_free (result);

    g_string_free (large_string, TRUE);
    searpc_free_client_with_pipe_transport(client);

    return NULL;
}
int SeafileRpcClient::getRepoFileStatus(const QString& repo_id,
                                        const QString& path_in_repo,
                                        bool isdir,
                                        QString *status)
{
    GError *error = NULL;
    char *ret = searpc_client_call__string (
        seafile_rpc_client_,
        "seafile_get_path_sync_status",
        &error, 3,
        "string", toCStr(repo_id),
        "string", toCStr(path_in_repo),
        "int", isdir ? 1 : 0);
    if (error) {
        qWarning("failed to get path status: %s\n", error->message);
        g_error_free(error);
        return -1;
    }

    *status = ret;

    g_free (ret);
    return 0;
}