#include "modest-account-assistant.h"
#include "modest-store-widget.h"
#include "modest-transport-widget.h"
+#include "modest-text-utils.h"
#include <modest-protocol-info.h>
#include <string.h>
gint pageno;
pageno = gtk_assistant_get_current_page (GTK_ASSISTANT(self));
- page = gtk_assistant_get_nth_page (GTK_ASSISTANT(self), pageno);
- gtk_assistant_set_page_complete (GTK_ASSISTANT(self), page, complete);
+ if (pageno != -1) {
+ page = gtk_assistant_get_nth_page (GTK_ASSISTANT(self), pageno);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT(self), page, complete);
+ }
}
/* FIXME: regexp check for email address */
txt = gtk_entry_get_text (GTK_ENTRY(priv->email));
- if (!txt || strlen(txt) == 0) {
+ if (!modest_text_utils_validate_email_address (txt))
set_current_page_complete (self, FALSE);
- return;
- }
- set_current_page_complete (self, TRUE);
+ else
+ set_current_page_complete (self, TRUE);
}
GSList*
modest_protocol_info_get_protocol_list (ModestProtocolType type)
{
- GSList *proto_list;
+ GSList *proto_list = NULL;
int i;
g_return_val_if_fail (type > MODEST_PROTOCOL_TYPE_UNKNOWN &&
ModestPairList*
modest_protocol_info_get_protocol_pair_list (ModestProtocolType type)
{
- ModestPairList *proto_list;
+ ModestPairList *proto_list = NULL;
int i;
g_return_val_if_fail (type > MODEST_PROTOCOL_TYPE_UNKNOWN && type < MODEST_PROTOCOL_TYPE_NUM,
return date_buf;
}
+
+gboolean
+modest_text_utils_validate_email_address (const gchar *email_address)
+{
+ int count = 0;
+ const gchar *c, *domain;
+ static gchar *rfc822_specials = "()<>@,;:\\\"[]";
+
+ /* first we validate the name portion (name@domain) */
+ for (c = email_address; *c; c++) {
+ if (*c == '\"' &&
+ (c == email_address ||
+ *(c - 1) == '.' ||
+ *(c - 1) == '\"')) {
+ while (*++c) {
+ if (*c == '\"')
+ break;
+ if (*c == '\\' && (*++c == ' '))
+ continue;
+ if (*c <= ' ' || *c >= 127)
+ return FALSE;
+ }
+ if (!*c++)
+ return FALSE;
+ if (*c == '@')
+ break;
+ if (*c != '.')
+ return FALSE;
+ continue;
+ }
+ if (*c == '@')
+ break;
+ if (*c <= ' ' || *c >= 127)
+ return FALSE;
+ if (strchr(rfc822_specials, *c))
+ return FALSE;
+ }
+ if (c == email_address || *(c - 1) == '.')
+ return FALSE;
+
+ /* next we validate the domain portion (name@domain) */
+ if (!*(domain = ++c))
+ return FALSE;
+ do {
+ if (*c == '.') {
+ if (c == domain || *(c - 1) == '.')
+ return FALSE;
+ count++;
+ }
+ if (*c <= ' ' || *c >= 127)
+ return FALSE;
+ if (strchr(rfc822_specials, *c))
+ return FALSE;
+ } while (*++c);
+
+ return (count >= 1) ? TRUE : FALSE;
+}
*/
const gchar* modest_text_utils_get_display_date (time_t date);
+
+/**
+ * modest_text_utils_validate_email_address:
+ * @email_address: a string
+ *
+ * validates the email address passed as argument
+ *
+ * Returns: TRUE if the address is valid, FALSE otherwise
+ **/
+gboolean modest_text_utils_validate_email_address (const gchar *email_address);
+
#endif /* __MODEST_TEXT_UTILS_H__ */
g_return_val_if_fail (folder, TNY_FOLDER_TYPE_UNKNOWN);
- type = tny_folder_get_folder_type ((TnyFolder*)folder); /* FIXME: cast tinymail */
+ type = tny_folder_get_folder_type (TNY_FOLDER (folder));
if (type == TNY_FOLDER_TYPE_UNKNOWN) {
const gchar *folder_name;