Initial commit (based on data-sharing-plugin)
[sharing-cli] / src / .svn / text-base / validate.c.svn-base
diff --git a/src/.svn/text-base/validate.c.svn-base b/src/.svn/text-base/validate.c.svn-base
new file mode 100644 (file)
index 0000000..83ceb2c
--- /dev/null
@@ -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 <stdio.h>
+#include <glib.h>
+#include <sharing-account.h>
+#include <sharing-http.h>
+#include <osso-log.h>
+#include <conicconnection.h>
+#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;
+}
+