X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-default-connection-policy.c;h=67a8b4f93f5165093e2ec357df6a7d909d4a67a0;hp=eac9e221b7d8113105292bad73638f45d764a493;hb=4d39841513a3a7f7aa9d38ab97cb9fcc9171e80b;hpb=a87b228eaa0848907bd3e7f722d644dc1cb2dbd4 diff --git a/src/modest-default-connection-policy.c b/src/modest-default-connection-policy.c index eac9e22..67a8b4f 100644 --- a/src/modest-default-connection-policy.c +++ b/src/modest-default-connection-policy.c @@ -1,15 +1,43 @@ -/* Your copyright here */ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include #include -#include - -#define MODEST_DEFAULT_CONNECTION_POLICY_C -gboolean exiting = FALSE; -#include -#undef MODEST_DEFAULT_CONNECTION_POLICY_C +#include "modest-default-connection-policy.h" +#include "modest-account-mgr.h" +#include "modest-account-mgr-helpers.h" +#include "modest-runtime.h" +#include "modest-tny-account.h" +#include "modest-ui-actions.h" #include +#include static GObjectClass *parent_class = NULL; @@ -22,6 +50,31 @@ modest_default_connection_policy_set_current (TnyConnectionPolicy *self, TnyAcco static void modest_default_connection_policy_on_connect (TnyConnectionPolicy *self, TnyAccount *account) { + /* Set the username as succedded */ + if (TNY_IS_STORE_ACCOUNT (account)) { + gboolean first_time = FALSE; + const gchar *id; + ModestAccountMgr *acc_mgr; + + acc_mgr = modest_runtime_get_account_mgr (); + id = tny_account_get_id (account); + first_time = !modest_account_mgr_get_server_account_username_has_succeeded (acc_mgr, id); + + /* If it's the first connection then perform a send&receive */ + if (first_time) { + const gchar *account_name; + ModestWindow *top_window; + + modest_account_mgr_set_server_account_username_has_succeeded (acc_mgr, id, TRUE); + + /* Perform a send receive */ + account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account); + top_window = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ()); + if (top_window) + modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, TRUE, top_window); + } + } + return; } @@ -34,7 +87,6 @@ modest_default_connection_policy_on_connection_broken (TnyConnectionPolicy *self static void modest_default_connection_policy_on_disconnect (TnyConnectionPolicy *self, TnyAccount *account) { - tny_account_cancel (account); return; }