/soc/2012/tomkiewicz/gg: 3d3f0584edf6: Gadu-Gadu: let's use bran...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Mon Aug 6 15:26:16 EDT 2012
Changeset: 3d3f0584edf65036e01c42b1ac73583ccde03495
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2012-08-06 21:26 +0200
Branch: soc.2012.gg
URL: http://hg.pidgin.im/soc/2012/tomkiewicz/gg/rev/3d3f0584edf6
Description:
Gadu-Gadu: let's use brand new validation for Request API (2)
diffstat:
libpurple/protocols/gg/validator.c | 66 ++++++++++++++++++++++++++++++++++++++
libpurple/protocols/gg/validator.h | 16 +++++++++
2 files changed, 82 insertions(+), 0 deletions(-)
diffs (92 lines):
diff --git a/libpurple/protocols/gg/validator.c b/libpurple/protocols/gg/validator.c
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/gg/validator.c
@@ -0,0 +1,66 @@
+#include "validator.h"
+
+#include "account.h"
+#include "utils.h"
+
+gboolean ggp_validator_token(PurpleRequestField *field, gchar **errmsg,
+ void *token)
+{
+ const char *value;
+
+ g_return_val_if_fail(field != NULL, FALSE);
+ g_return_val_if_fail(purple_request_field_get_type(field) ==
+ PURPLE_REQUEST_FIELD_STRING, FALSE);
+
+ value = purple_request_field_string_get_value(field);
+
+ if (value != NULL && ggp_account_token_validate(token, value))
+ return TRUE;
+
+ if (errmsg)
+ *errmsg = g_strdup(_("Captcha validation failed"));
+ return FALSE;
+}
+
+gboolean ggp_validator_password(PurpleRequestField *field, gchar **errmsg,
+ void *user_data)
+{
+ const char *value;
+
+ g_return_val_if_fail(field != NULL, FALSE);
+ g_return_val_if_fail(purple_request_field_get_type(field) ==
+ PURPLE_REQUEST_FIELD_STRING, FALSE);
+
+ value = purple_request_field_string_get_value(field);
+
+ if (value != NULL && ggp_password_validate(value))
+ return TRUE;
+
+ if (errmsg)
+ *errmsg = g_strdup(_("Password can contain 6-15 alphanumeric characters"));
+ return FALSE;
+}
+
+gboolean ggp_validator_password_equal(PurpleRequestField *field, gchar **errmsg,
+ void *field2_p)
+{
+ const char *value1, *value2;
+ PurpleRequestField *field2 = field2_p;
+
+ g_return_val_if_fail(field != NULL, FALSE);
+ g_return_val_if_fail(field2 != NULL, FALSE);
+ g_return_val_if_fail(purple_request_field_get_type(field) ==
+ PURPLE_REQUEST_FIELD_STRING, FALSE);
+ g_return_val_if_fail(purple_request_field_get_type(field2) ==
+ PURPLE_REQUEST_FIELD_STRING, FALSE);
+
+ value1 = purple_request_field_string_get_value(field);
+ value2 = purple_request_field_string_get_value(field2);
+
+ if (g_strcmp0(value1, value2) == 0)
+ return TRUE;
+
+ if (errmsg)
+ *errmsg = g_strdup(_("Passwords do not match"));
+ return FALSE;
+}
diff --git a/libpurple/protocols/gg/validator.h b/libpurple/protocols/gg/validator.h
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/gg/validator.h
@@ -0,0 +1,16 @@
+#ifndef _GGP_VALIDATOR_H
+#define _GGP_VALIDATOR_H
+
+#include <internal.h>
+#include <request.h>
+
+gboolean ggp_validator_token(PurpleRequestField *field, gchar **errmsg,
+ void *token);
+
+gboolean ggp_validator_password(PurpleRequestField *field, gchar **errmsg,
+ void *user_data);
+
+gboolean ggp_validator_password_equal(PurpleRequestField *field, gchar **errmsg,
+ void *field2);
+
+#endif /* _GGP_VALIDATOR_H */
More information about the Commits
mailing list