rename accountopt.[ch] to purpleaccountoption.[ch]
[pidgin-git.git] / libpurple / protocols / gg / validator.c
blob2f884eeec36d77de5bae5453904c0c52ec883a27
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * Rewritten from scratch during Google Summer of Code 2012
8 * by Tomek Wasilczyk (http://www.wasilczyk.pl).
10 * Previously implemented by:
11 * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001);
12 * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005;
13 * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011).
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
30 #include "validator.h"
32 #include "utils.h"
34 gboolean ggp_validator_password(PurpleRequestField *field, gchar **errmsg,
35 void *user_data)
37 const char *value;
39 g_return_val_if_fail(field != NULL, FALSE);
40 g_return_val_if_fail(purple_request_field_get_field_type(field) ==
41 PURPLE_REQUEST_FIELD_STRING, FALSE);
43 value = purple_request_field_string_get_value(field);
45 if (value != NULL && ggp_password_validate(value))
46 return TRUE;
48 if (errmsg)
49 *errmsg = g_strdup(_("Password can contain 6-15 alphanumeric characters"));
50 return FALSE;
53 gboolean ggp_validator_password_equal(PurpleRequestField *field, gchar **errmsg,
54 void *field2_p)
56 const char *value1, *value2;
57 PurpleRequestField *field2 = field2_p;
59 g_return_val_if_fail(field != NULL, FALSE);
60 g_return_val_if_fail(field2 != NULL, FALSE);
61 g_return_val_if_fail(purple_request_field_get_field_type(field) ==
62 PURPLE_REQUEST_FIELD_STRING, FALSE);
63 g_return_val_if_fail(purple_request_field_get_field_type(field2) ==
64 PURPLE_REQUEST_FIELD_STRING, FALSE);
66 value1 = purple_request_field_string_get_value(field);
67 value2 = purple_request_field_string_get_value(field2);
69 if (g_strcmp0(value1, value2) == 0)
70 return TRUE;
72 if (errmsg)
73 *errmsg = g_strdup(_("Passwords do not match"));
74 return FALSE;