X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fvalidate.c;fp=src%2Fvalidate.c;h=83ceb2cfa0dff9b31812e97bf859848cd2c6bdc1;hb=3419a53b563d0cce238372985421a83504680760;hp=0000000000000000000000000000000000000000;hpb=8cef44b33a1ba4668fc56ab330a5c8c96f0d1486;p=sharing-cli diff --git a/src/validate.c b/src/validate.c new file mode 100644 index 0000000..83ceb2c --- /dev/null +++ b/src/validate.c @@ -0,0 +1,55 @@ +/* + * This file is part of sharing-plugin-template + * + * Copyright (C) 2008-2009 Nokia Corporation. All rights reserved. + * + * This maemo code example is licensed under a MIT-style license, + * that can be found in the file called "COPYING" in the root + * directory. + * + */ + +#include +#include +#include +#include +#include +#include +#include "validate.h" +#include "common.h" + +/** + * test: + * @account: #SharingAccount to be tested + * @con: Connection used + * @dead_mans_switch: Turn to %FALSE at least every 30 seconds. + * + * Test if #SharingAccount is valid. + * + * Returns: #SharingPluginInterfaceTestAccountResult + */ +SharingPluginInterfaceAccountValidateResult validate (SharingAccount* account, + ConIcConnection* con, gboolean *cont, gboolean* dead_mans_switch) +{ + SharingPluginInterfaceAccountValidateResult ret = + SHARING_ACCOUNT_VALIDATE_SUCCESS; + + SharingHTTP * http = sharing_http_new (); + + /* Correct fields must be added to http request before sending */ + + SharingHTTPRunResponse res; + res = sharing_http_run (http, "http://example.com/post"); + if (res == SHARING_HTTP_RUNRES_SUCCESS) { + ULOG_DEBUG_L ("Got response (%d): %s\n", sharing_http_get_res_code (http), + sharing_http_get_res_body (http, NULL)); + } else { + ULOG_ERR_L ("Couldn't get stuff from service\n"); + ret = SHARING_ACCOUNT_VALIDATE_FAILED; + } + sharing_http_unref (http); + + + return ret; +} +