/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Authors: Michael Zucchi * * Copyright 2001-2003 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "camel-sasl-popb4smtp.h" #include "camel-service.h" #include "camel-session.h" CamelServiceAuthType camel_sasl_popb4smtp_authtype = { N_("POP before SMTP"), N_("This option will authorise a POP connection before attempting SMTP"), "POPB4SMTP", FALSE, }; /* last time the pop was accessed (through the auth method anyway), *time_t */ static GHashTable *poplast; /* use 1 hour as our pop timeout */ #define POPB4SMTP_TIMEOUT (60*60) static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; #define POPB4SMTP_LOCK(l) pthread_mutex_lock(&l) #define POPB4SMTP_UNLOCK(l) pthread_mutex_unlock(&l) static CamelSaslClass *parent_class = NULL; /* Returns the class for a CamelSaslPOPB4SMTP */ #define CSP_CLASS(so) CAMEL_SASL_POPB4SMTP_CLASS (CAMEL_OBJECT_GET_CLASS (so)) static GByteArray *popb4smtp_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex); static void camel_sasl_popb4smtp_class_init (CamelSaslPOPB4SMTPClass *camel_sasl_popb4smtp_class) { CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_popb4smtp_class); parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ())); /* virtual method overload */ camel_sasl_class->challenge = popb4smtp_challenge; poplast = g_hash_table_new(g_str_hash, g_str_equal); } CamelType camel_sasl_popb4smtp_get_type (void) { static CamelType type = CAMEL_INVALID_TYPE; if (type == CAMEL_INVALID_TYPE) { type = camel_type_register (camel_sasl_get_type (), "CamelSaslPOPB4SMTP", sizeof (CamelSaslPOPB4SMTP), sizeof (CamelSaslPOPB4SMTPClass), (CamelObjectClassInitFunc) camel_sasl_popb4smtp_class_init, NULL, NULL, NULL); } return type; } static GByteArray * popb4smtp_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex) { char *popuri; CamelSession *session = sasl->service->session; CamelStore *store; time_t now, *timep; sasl->authenticated = FALSE; popuri = camel_session_get_password (session, _("POP Source URI"), 0, sasl->service, "popb4smtp_uri", ex); if (popuri == NULL) { camel_exception_setv(ex, 1, _("POP Before SMTP auth using an unknown transport")); return NULL; } if (strncasecmp(popuri, "pop:", 4) != 0) { camel_exception_setv(ex, 1, _("POP Before SMTP auth using a non-pop source")); return NULL; } /* check if we've done it before recently in this session */ now = time(0); /* need to lock around the whole thing until finished with timep */ POPB4SMTP_LOCK(lock); timep = g_hash_table_lookup(poplast, popuri); if (timep) { if ((*timep + POPB4SMTP_TIMEOUT) > now) { sasl->authenticated = TRUE; POPB4SMTP_UNLOCK(lock); g_free(popuri); return NULL; } } else { timep = g_malloc0(sizeof(*timep)); g_hash_table_insert(poplast, g_strdup(popuri), timep); } /* connect to pop session */ store = camel_session_get_store(session, popuri, ex); if (store) { sasl->authenticated = TRUE; camel_object_unref((CamelObject *)store); *timep = now; } else { sasl->authenticated = FALSE; *timep = 0; } POPB4SMTP_UNLOCK(lock); g_free(popuri); return NULL; } Yuri Myasoedov2011-03-271-29/+29 * Updated Russian translationYuri Myasoedov2011-03-111-7968/+5837 * Updated Russian translation from Yuri MyasoedovLeonid Kanter2010-09-091-5716/+6231 * added Russian translationLeonid Kanter2010-03-191-21/+21 * updated Russian translationLeonid Kanter2010-03-191-281/+152 * updated Russian translation fromLeonid Kanter2010-03-181-2364/+2356 * Update Russian translationLeonid Kanter2010-02-241-302/+254 * partially update Russian translationLeonid Kanter2010-02-221-2762/+2879 * partially update Russian translationLeonid Kanter2010-02-221-6033/+4753 * Updated Russian translationLeonid Kanter2009-10-201-11026/+10848 * Updated Russian translation by Yuriy Penkin.Nickolay V. Shmyrev2009-03-151-1117/+1245 * Updated Russian translation.Nickolay V. Shmyrev2009-01-191-2178/+2144 * Updated Russian translation.Nickolay V. Shmyrev2008-11-161-1977/+2103 * Updated Russian translation.Nickolay V. Shmyrev2008-09-221-32/+122 * Updated Russian translation.Nickolay V. Shmyrev2008-09-221-2621/+2804 * Updated Russian translationLeonid Kanter2008-08-041-1884/+2015 * Updated Russian translation by Anatol Kamynin.Nickolay V. Shmyrev2008-06-151-3483/+3918 * Updated Russian translation.Vasiliy Faronov2008-03-101-1504/+1702 * Updated Russian translationLeonid Kanter2008-01-161-2740/+3029 * Updated Russian translation.Nickolay V. Shmyrev2007-09-151-3564/+4144 * Updated Russian translationLeonid Kanter2007-02-271-82/+90 * Updated Russian translationLeonid Kanter2007-02-221-50/+65 * Updated Russian translationLeonid Kanter2007-02-151-1526/+1801 * Updated Russian translation.Nickolay V. Shmyrev2006-09-241-665/+758 * Updated Russian translationLeonid Kanter2006-08-181-161/+179 * Updated Russian translationLeonid Kanter2006-08-091-2619/+3043 * Fixed Russian translationLeonid Kanter2006-03-061-5/+3 * Updated Russian translationLeonid Kanter2006-03-011-98/+120 * Updated Russian translationLeonid Kanter2006-02-171-1136/+1159 * Updated Russian translationLeonid Kanter2006-02-161-3960/+4985 * Updated Russian translation.Nickolay V. Shmyrev2005-09-301-421/+429 * removed outdated strings and run "mak update-po".Tomasz Kłoczko2005-09-111-783/+858 * Updated Russian translationLeonid Kanter2005-08-251-596/+525 * Updated Russian translationNickolay V. Shmyrev2005-08-231-2539/+1121 * Fixed strings encodingNickolay V. Shmyrev2005-08-221-1/+1 * Updated Russian translationNickolay V. Shmyrev2005-08-211-3118/+5161 * added all the new gal widgets & a couple of other missing files. re-sortedNot Zed2005-06-211-5962/+7400 * Updated Russian translationLeonid Kanter2005-02-231-1680/+1730 * Updated Russian translationLeonid Kanter2005-02-221-69/+70 * Updated Russian translationLeonid Kanter2005-02-111-718/+935 * Updated Russian translationLeonid Kanter2005-02-101-4/+4 * Updated Russian translationLeonid Kanter2005-02-011-6933/+5295 * Updated Russian translationLeonid Kanter2004-09-011-882/+791 * bump version. requiresJP Rosevear2004-08-141-194/+274 * update Russian translationLeonid Kanter2004-08-121-467/+546 * updated Russian translationLeonid Kanter2004-08-111-258/+175 * update Russian translationLeonid Kanter2004-08-111-1027/+438 * bump version, requirementsJP Rosevear2004-08-031-567/+700 * bump version, requirementsJP Rosevear2004-07-201-3262/+4396 * update Russian translationLeonid Kanter2004-07-131-56/+33 * update Russian translationLeonid Kanter2004-07-121-4724/+3427 * bump version, requirementsJP Rosevear2004-07-051-3178/+4256 * corrected %%+05d translationLeonid Kanter2004-06-151-1774/+69 * Merge from release branch.JP Rosevear2004-06-041-1889/+1905 * bump versionJP Rosevear2004-05-201-3046/+3850 * distedJeffrey Stedfast2004-04-301-1906/+2742 * Merge from release branchJP Rosevear2004-04-201-793/+840 * bump version, requirementsJP Rosevear2004-04-031-2209/+2751 * bump version, requirementsJP Rosevear2004-03-061-1548/+1787 * update Russian translationLeonid Kanter2004-02-271-790/+443 * bump version, libtool numbersJP Rosevear2004-02-101-1219/+1360 * bump requirements, versionJP Rosevear2004-01-271-1393/+1696 * ru.po: Updated Russian translation from Russian team <gnome-cyr@gnome.org>.Dmitry Mastrukov2004-01-241-10652/+632 * bump version and requirementsJP Rosevear2004-01-131-1431/+2025 * bump version and gal, e-d-s and gtkhtml requirementsJP Rosevear2003-12-301-1490/+1678 * update version relianceJP Rosevear2003-12-081-2251/+3560 * updateJP Rosevear2003-11-071-1270/+1082 * remove dead fileJP Rosevear2003-10-311-14525/+12679 * 1.4.1 release.Ettore Perazzoli2003-06-261-556/+570 * 1.4.0!Ettore Perazzoli2003-06-031-297/+297 * ru.po: Updated Russian translation from Russian team <gnome-cyr@gnome.org>.Dmitry Mastrukov2003-05-301-254/+175 * Sync 1.3.92.Ettore Perazzoli2003-05-231-3/+3 * 1.3.91.Ettore Perazzoli2003-05-221-403/+447 * ru.po: Updated Russian translation from Russian team <gnome-cyr@gnome.org>.Dmitry Mastrukov2003-05-191-2248/+678 * 1.3.3.Ettore Perazzoli2003-04-301-801/+928 * The return of 1.3.2.Ettore Perazzoli2003-04-121-204/+204 * Sync for 1.3.2.Ettore Perazzoli2003-04-101-5320/+6079 * ru.po: Updated Russian translation from Russian team <gnome-cyr@gnome.org>.Dmitry Mastrukov2003-02-181-63/+83 * ru.po: Updated Russian translation from Russian team <gnome-cyr@gnome.org>.Dmitry Mastrukov2003-02-121-4588/+4309 * ru.po: Updated Russian translation from Russian team <gnome-cyr@gnome.org>.Dmitry Mastrukov2003-02-051-4899/+5156 * - 3329 translated messages, 344 fuzzy translations, 2651 untranslated messages.Andrew V. Samoilov2002-12-261-156/+119 * - 3173 translated messages, 460 fuzzy translations, 2691 untranslated messages.Andrew V. Samoilov2002-12-251-312/+208 * Sync for 1.1.90.Ettore Perazzoli2002-10-291-1010/+1078 * Sync for 1.1.2.Ettore Perazzoli2002-10-081-1456/+1674 * Sync for 1.1.1.Ettore Perazzoli2002-09-101-1165/+1264 * Update po files to speed up snap build.JP Rosevear2002-08-131-1751/+2227 * Update .po files.JP Rosevear2002-06-281-3281/+4332 * Updated Russian translation.Andrew V. Samoilov2002-06-131-351/+148 * Update the po files to cut down on dist timeJP Rosevear2002-05-081-3096/+4780 * Fix typosAndrew V. Samoilov2002-04-121-25/+25