]> git.0d.be Git - empathy.git/blob - libempathy/empathy-idle.c
add myself to AUTHORS
[empathy.git] / libempathy / empathy-idle.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2007-2008 Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * Authors: Xavier Claessens <xclaesse@gmail.com>
20  */
21
22 #include <config.h>
23
24 #include <string.h>
25
26 #include <glib/gi18n-lib.h>
27 #include <dbus/dbus-glib.h>
28
29 #include <telepathy-glib/account-manager.h>
30 #include <telepathy-glib/dbus.h>
31 #include <telepathy-glib/util.h>
32
33 #include "empathy-idle.h"
34 #include "empathy-utils.h"
35 #include "empathy-connectivity.h"
36
37 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
38 #include "empathy-debug.h"
39
40 /* Number of seconds before entering extended autoaway. */
41 #define EXT_AWAY_TIME (30*60)
42
43 /* Number of seconds to consider an account in the "just connected" state
44  * for. */
45 #define ACCOUNT_IS_JUST_CONNECTED_SECONDS 10
46
47 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIdle)
48 typedef struct {
49         DBusGProxy     *gs_proxy;
50         EmpathyConnectivity *connectivity;
51         gulong state_change_signal_id;
52
53         gboolean ready;
54
55         TpConnectionPresenceType      state;
56         gchar          *status;
57         gboolean        auto_away;
58
59         TpConnectionPresenceType      away_saved_state;
60         TpConnectionPresenceType      saved_state;
61         gchar          *saved_status;
62
63         gboolean        is_idle;
64         guint           ext_away_timeout;
65
66         TpAccountManager *manager;
67
68         /* pointer to a TpAccount --> glong of time of connection */
69         GHashTable *connect_times;
70
71         TpConnectionPresenceType requested_presence_type;
72         gchar *requested_status_message;
73
74 } EmpathyIdlePriv;
75
76 typedef enum {
77         SESSION_STATUS_AVAILABLE,
78         SESSION_STATUS_INVISIBLE,
79         SESSION_STATUS_BUSY,
80         SESSION_STATUS_IDLE,
81         SESSION_STATUS_UNKNOWN
82 } SessionStatus;
83
84 enum {
85         PROP_0,
86         PROP_STATE,
87         PROP_STATUS,
88         PROP_AUTO_AWAY
89 };
90
91 G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT);
92
93 static EmpathyIdle * idle_singleton = NULL;
94
95 static const gchar *presence_type_to_status[NUM_TP_CONNECTION_PRESENCE_TYPES] = {
96         NULL,
97         "offline",
98         "available",
99         "away",
100         "xa",
101         "hidden",
102         "busy",
103         NULL,
104         NULL,
105 };
106
107 static void
108 idle_presence_changed_cb (TpAccountManager *manager,
109                           TpConnectionPresenceType state,
110                           gchar          *status,
111                           gchar          *status_message,
112                           EmpathyIdle    *idle)
113 {
114         EmpathyIdlePriv *priv;
115
116         priv = GET_PRIV (idle);
117
118         if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET)
119                 /* Assume our presence is offline if MC reports UNSET */
120                 state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
121
122         DEBUG ("Presence changed to '%s' (%d) \"%s\"", status, state,
123                 status_message);
124
125         g_free (priv->status);
126         priv->state = state;
127         if (EMP_STR_EMPTY (status_message))
128                 priv->status = NULL;
129         else
130                 priv->status = g_strdup (status_message);
131
132         g_object_notify (G_OBJECT (idle), "state");
133         g_object_notify (G_OBJECT (idle), "status");
134 }
135
136 static gboolean
137 idle_ext_away_cb (EmpathyIdle *idle)
138 {
139         EmpathyIdlePriv *priv;
140
141         priv = GET_PRIV (idle);
142
143         DEBUG ("Going to extended autoaway");
144         empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY);
145         priv->ext_away_timeout = 0;
146
147         return FALSE;
148 }
149
150 static void
151 idle_ext_away_stop (EmpathyIdle *idle)
152 {
153         EmpathyIdlePriv *priv;
154
155         priv = GET_PRIV (idle);
156
157         if (priv->ext_away_timeout) {
158                 g_source_remove (priv->ext_away_timeout);
159                 priv->ext_away_timeout = 0;
160         }
161 }
162
163 static void
164 idle_ext_away_start (EmpathyIdle *idle)
165 {
166         EmpathyIdlePriv *priv;
167
168         priv = GET_PRIV (idle);
169
170         if (priv->ext_away_timeout != 0) {
171                 return;
172         }
173         priv->ext_away_timeout = g_timeout_add_seconds (EXT_AWAY_TIME,
174                                                         (GSourceFunc) idle_ext_away_cb,
175                                                         idle);
176 }
177
178 static void
179 idle_session_status_changed_cb (DBusGProxy    *gs_proxy,
180                                 SessionStatus  status,
181                                 EmpathyIdle   *idle)
182 {
183         EmpathyIdlePriv *priv;
184         gboolean is_idle;
185
186         priv = GET_PRIV (idle);
187
188         is_idle = (status == SESSION_STATUS_IDLE);
189
190         DEBUG ("Session idle state changed, %s -> %s",
191                 priv->is_idle ? "yes" : "no",
192                 is_idle ? "yes" : "no");
193
194         if (!priv->auto_away ||
195             (priv->saved_state == TP_CONNECTION_PRESENCE_TYPE_UNSET &&
196              (priv->state <= TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
197               priv->state == TP_CONNECTION_PRESENCE_TYPE_HIDDEN))) {
198                 /* We don't want to go auto away OR we explicitely asked to be
199                  * offline, nothing to do here */
200                 priv->is_idle = is_idle;
201                 return;
202         }
203
204         if (is_idle && !priv->is_idle) {
205                 TpConnectionPresenceType new_state;
206                 /* We are now idle */
207
208                 idle_ext_away_start (idle);
209
210                 if (priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
211                         /* We are disconnected, when coming back from away
212                          * we want to restore the presence before the
213                          * disconnection. */
214                         priv->away_saved_state = priv->saved_state;
215                 } else {
216                         priv->away_saved_state = priv->state;
217                 }
218
219                 new_state = TP_CONNECTION_PRESENCE_TYPE_AWAY;
220                 if (priv->state == TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY) {
221                         new_state = TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY;
222                 }
223
224                 DEBUG ("Going to autoaway. Saved state=%d, new state=%d",
225                         priv->away_saved_state, new_state);
226                 empathy_idle_set_state (idle, new_state);
227         } else if (!is_idle && priv->is_idle) {
228                 const gchar *new_status;
229                 /* We are no more idle, restore state */
230
231                 idle_ext_away_stop (idle);
232
233                 if (priv->away_saved_state == TP_CONNECTION_PRESENCE_TYPE_AWAY ||
234                     priv->away_saved_state == TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY) {
235                         priv->away_saved_state = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
236                         new_status = NULL;
237                 } else {
238                         new_status = priv->status;
239                 }
240
241                 /* Only try and set the presence if the away saved state is not
242                  * unset. This is an odd case because it means that the session
243                  * didn't notify us of the state change to idle, and as a
244                  * result, we couldn't save the current state at that time.
245                  */
246                 if (priv->away_saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
247                         DEBUG ("Restoring state to %d, reset status to %s",
248                                 priv->away_saved_state, new_status);
249
250                         empathy_idle_set_presence (idle,
251                                                    priv->away_saved_state,
252                                                    new_status);
253                 } else {
254                         DEBUG ("Away saved state is unset. This means that we "
255                                "weren't told when the session went idle. "
256                                "As a result, I'm not trying to set presence");
257                 }
258
259                 priv->away_saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
260         }
261
262         priv->is_idle = is_idle;
263 }
264
265 static void
266 idle_state_change_cb (EmpathyConnectivity *connectivity,
267                       gboolean new_online,
268                       EmpathyIdle *idle)
269 {
270         EmpathyIdlePriv *priv;
271
272         priv = GET_PRIV (idle);
273
274         if (!new_online) {
275                 /* We are no longer connected */
276                 DEBUG ("Disconnected: Save state %d (%s)",
277                                 priv->state, priv->status);
278                 priv->saved_state = priv->state;
279                 g_free (priv->saved_status);
280                 priv->saved_status = g_strdup (priv->status);
281                 empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
282         }
283         else if (new_online
284                         && priv->saved_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
285                 /* We are now connected */
286                 DEBUG ("Reconnected: Restore state %d (%s)",
287                                 priv->saved_state, priv->saved_status);
288                 empathy_idle_set_presence (idle,
289                                 priv->saved_state,
290                                 priv->saved_status);
291                 priv->saved_state = TP_CONNECTION_PRESENCE_TYPE_UNSET;
292                 g_free (priv->saved_status);
293                 priv->saved_status = NULL;
294         }
295 }
296
297 static void
298 idle_finalize (GObject *object)
299 {
300         EmpathyIdlePriv *priv;
301
302         priv = GET_PRIV (object);
303
304         g_free (priv->status);
305         g_free (priv->requested_status_message);
306
307         if (priv->gs_proxy) {
308                 g_object_unref (priv->gs_proxy);
309         }
310
311         g_signal_handler_disconnect (priv->connectivity,
312                                      priv->state_change_signal_id);
313         priv->state_change_signal_id = 0;
314
315         g_object_unref (priv->connectivity);
316
317         g_hash_table_destroy (priv->connect_times);
318         priv->connect_times = NULL;
319
320         idle_ext_away_stop (EMPATHY_IDLE (object));
321 }
322
323 static GObject *
324 idle_constructor (GType type,
325                   guint n_props,
326                   GObjectConstructParam *props)
327 {
328         GObject *retval;
329
330         if (idle_singleton) {
331                 retval = g_object_ref (idle_singleton);
332         } else {
333                 retval = G_OBJECT_CLASS (empathy_idle_parent_class)->constructor
334                         (type, n_props, props);
335
336                 idle_singleton = EMPATHY_IDLE (retval);
337                 g_object_add_weak_pointer (retval, (gpointer) &idle_singleton);
338         }
339
340         return retval;
341 }
342
343 static const gchar *
344 empathy_idle_get_status (EmpathyIdle *idle)
345 {
346         EmpathyIdlePriv *priv;
347
348         priv = GET_PRIV (idle);
349
350         if (G_UNLIKELY (!priv->ready))
351                 g_critical (G_STRLOC ": %s called before AccountManager ready",
352                                 G_STRFUNC);
353
354         if (!priv->status) {
355                 return empathy_presence_get_default_message (priv->state);
356         }
357
358         return priv->status;
359 }
360
361 static void
362 idle_get_property (GObject    *object,
363                    guint       param_id,
364                    GValue     *value,
365                    GParamSpec *pspec)
366 {
367         EmpathyIdlePriv *priv;
368         EmpathyIdle     *idle;
369
370         priv = GET_PRIV (object);
371         idle = EMPATHY_IDLE (object);
372
373         switch (param_id) {
374         case PROP_STATE:
375                 g_value_set_enum (value, empathy_idle_get_state (idle));
376                 break;
377         case PROP_STATUS:
378                 g_value_set_string (value, empathy_idle_get_status (idle));
379                 break;
380         case PROP_AUTO_AWAY:
381                 g_value_set_boolean (value, empathy_idle_get_auto_away (idle));
382                 break;
383         default:
384                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
385                 break;
386         };
387 }
388
389 static void
390 idle_set_property (GObject      *object,
391                    guint         param_id,
392                    const GValue *value,
393                    GParamSpec   *pspec)
394 {
395         EmpathyIdlePriv *priv;
396         EmpathyIdle     *idle;
397
398         priv = GET_PRIV (object);
399         idle = EMPATHY_IDLE (object);
400
401         switch (param_id) {
402         case PROP_STATE:
403                 empathy_idle_set_state (idle, g_value_get_enum (value));
404                 break;
405         case PROP_STATUS:
406                 empathy_idle_set_status (idle, g_value_get_string (value));
407                 break;
408         case PROP_AUTO_AWAY:
409                 empathy_idle_set_auto_away (idle, g_value_get_boolean (value));
410                 break;
411         default:
412                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
413                 break;
414         };
415 }
416
417 static void
418 empathy_idle_class_init (EmpathyIdleClass *klass)
419 {
420         GObjectClass *object_class = G_OBJECT_CLASS (klass);
421
422         object_class->finalize = idle_finalize;
423         object_class->constructor = idle_constructor;
424         object_class->get_property = idle_get_property;
425         object_class->set_property = idle_set_property;
426
427         g_object_class_install_property (object_class,
428                                          PROP_STATE,
429                                          g_param_spec_uint ("state",
430                                                             "state",
431                                                             "state",
432                                                             0, NUM_TP_CONNECTION_PRESENCE_TYPES,
433                                                             TP_CONNECTION_PRESENCE_TYPE_UNSET,
434                                                             G_PARAM_READWRITE));
435         g_object_class_install_property (object_class,
436                                          PROP_STATUS,
437                                          g_param_spec_string ("status",
438                                                               "status",
439                                                               "status",
440                                                               NULL,
441                                                               G_PARAM_READWRITE));
442
443          g_object_class_install_property (object_class,
444                                           PROP_AUTO_AWAY,
445                                           g_param_spec_boolean ("auto-away",
446                                                                 "Automatic set presence to away",
447                                                                 "Should it set presence to away if inactive",
448                                                                 FALSE,
449                                                                 G_PARAM_READWRITE));
450
451         g_type_class_add_private (object_class, sizeof (EmpathyIdlePriv));
452 }
453
454 static void
455 account_status_changed_cb (TpAccount  *account,
456                            guint       old_status,
457                            guint       new_status,
458                            guint       reason,
459                            gchar      *dbus_error_name,
460                            GHashTable *details,
461                            gpointer    user_data)
462 {
463         EmpathyIdle *idle = EMPATHY_IDLE (user_data);
464         EmpathyIdlePriv *priv = GET_PRIV (idle);
465         GTimeVal val;
466
467         if (new_status == TP_CONNECTION_STATUS_CONNECTED) {
468                 g_get_current_time (&val);
469                 g_hash_table_insert (priv->connect_times, account,
470                                      GINT_TO_POINTER (val.tv_sec));
471         } else if (new_status == TP_CONNECTION_STATUS_DISCONNECTED) {
472                 g_hash_table_remove (priv->connect_times, account);
473         }
474 }
475
476 static void
477 account_manager_ready_cb (GObject *source_object,
478                           GAsyncResult *result,
479                           gpointer user_data)
480 {
481         EmpathyIdle *idle = EMPATHY_IDLE (user_data);
482         TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
483         EmpathyIdlePriv *priv = GET_PRIV (idle);
484         TpConnectionPresenceType state;
485         gchar *status, *status_message;
486         GList *accounts, *l;
487         GError *error = NULL;
488
489         priv->ready = TRUE;
490
491         if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
492                 DEBUG ("Failed to prepare account manager: %s", error->message);
493                 g_error_free (error);
494                 return;
495         }
496
497         state = tp_account_manager_get_most_available_presence (priv->manager,
498                 &status, &status_message);
499
500         idle_presence_changed_cb (account_manager, state, status,
501                 status_message, idle);
502
503         accounts = tp_account_manager_get_valid_accounts (priv->manager);
504         for (l = accounts; l != NULL; l = l->next) {
505                 empathy_signal_connect_weak (l->data, "status-changed",
506                                              G_CALLBACK (account_status_changed_cb),
507                                              G_OBJECT (idle));
508         }
509         g_list_free (accounts);
510
511         g_free (status);
512         g_free (status_message);
513 }
514
515 static void
516 empathy_idle_init (EmpathyIdle *idle)
517 {
518         EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle,
519                 EMPATHY_TYPE_IDLE, EmpathyIdlePriv);
520
521         idle->priv = priv;
522         priv->is_idle = FALSE;
523
524         priv->manager = tp_account_manager_dup ();
525
526         tp_account_manager_prepare_async (priv->manager, NULL,
527             account_manager_ready_cb, idle);
528
529         g_signal_connect (priv->manager, "most-available-presence-changed",
530                 G_CALLBACK (idle_presence_changed_cb), idle);
531
532         priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (),
533                                                     "org.gnome.SessionManager",
534                                                     "/org/gnome/SessionManager/Presence",
535                                                     "org.gnome.SessionManager.Presence");
536         if (priv->gs_proxy) {
537                 dbus_g_proxy_add_signal (priv->gs_proxy, "StatusChanged",
538                                          G_TYPE_UINT, G_TYPE_INVALID);
539                 dbus_g_proxy_connect_signal (priv->gs_proxy, "StatusChanged",
540                                              G_CALLBACK (idle_session_status_changed_cb),
541                                              idle, NULL);
542         } else {
543                 DEBUG ("Failed to get gs proxy");
544         }
545
546         priv->connectivity = empathy_connectivity_dup_singleton ();
547         priv->state_change_signal_id = g_signal_connect (priv->connectivity,
548             "state-change", G_CALLBACK (idle_state_change_cb), idle);
549
550         priv->connect_times = g_hash_table_new (g_direct_hash, g_direct_equal);
551 }
552
553 EmpathyIdle *
554 empathy_idle_dup_singleton (void)
555 {
556         return g_object_new (EMPATHY_TYPE_IDLE, NULL);
557 }
558
559 TpConnectionPresenceType
560 empathy_idle_get_state (EmpathyIdle *idle)
561 {
562         EmpathyIdlePriv *priv;
563
564         priv = GET_PRIV (idle);
565
566         if (G_UNLIKELY (!priv->ready))
567                 g_critical (G_STRLOC ": %s called before AccountManager ready",
568                                 G_STRFUNC);
569
570         return priv->state;
571 }
572
573 void
574 empathy_idle_set_state (EmpathyIdle *idle,
575                         TpConnectionPresenceType   state)
576 {
577         EmpathyIdlePriv *priv;
578
579         priv = GET_PRIV (idle);
580
581         empathy_idle_set_presence (idle, state, priv->status);
582 }
583
584 void
585 empathy_idle_set_status (EmpathyIdle *idle,
586                          const gchar *status)
587 {
588         EmpathyIdlePriv *priv;
589
590         priv = GET_PRIV (idle);
591
592         empathy_idle_set_presence (idle, priv->state, status);
593 }
594
595 static void
596 empathy_idle_do_set_presence (EmpathyIdle *idle,
597                            TpConnectionPresenceType status_type,
598                            const gchar *status_message)
599 {
600         EmpathyIdlePriv *priv = GET_PRIV (idle);
601         const gchar *status;
602
603         g_assert (status_type > 0 && status_type < NUM_TP_CONNECTION_PRESENCE_TYPES);
604
605         status = presence_type_to_status[status_type];
606
607         g_return_if_fail (status != NULL);
608
609         /* We possibly should be sure that the account manager is prepared, but
610          * sometimes this isn't possible, like when exiting. In other words,
611          * we need a callback to empathy_idle_set_presence to be sure the
612          * presence is set on all accounts successfully.
613          * However, in practice, this is fine as we've already prepared the
614          * account manager here in _init. */
615         tp_account_manager_set_all_requested_presences (priv->manager,
616                 status_type, status, status_message);
617 }
618
619 void
620 empathy_idle_set_presence (EmpathyIdle *idle,
621                            TpConnectionPresenceType   state,
622                            const gchar *status)
623 {
624         EmpathyIdlePriv *priv;
625         const gchar     *default_status;
626
627         priv = GET_PRIV (idle);
628
629         DEBUG ("Changing presence to %s (%d)", status, state);
630
631         g_free (priv->requested_status_message);
632         priv->requested_presence_type = state;
633         priv->requested_status_message = g_strdup (status);
634
635         /* Do not set translated default messages */
636         default_status = empathy_presence_get_default_message (state);
637         if (!tp_strdiff (status, default_status)) {
638                 status = NULL;
639         }
640
641         if (state != TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
642                         !empathy_connectivity_is_online (priv->connectivity)) {
643                 DEBUG ("Empathy is not online");
644
645                 priv->saved_state = state;
646                 if (tp_strdiff (priv->status, status)) {
647                         g_free (priv->saved_status);
648                         priv->saved_status = NULL;
649                         if (!EMP_STR_EMPTY (status)) {
650                                 priv->saved_status = g_strdup (status);
651                         }
652                 }
653                 return;
654         }
655
656         empathy_idle_do_set_presence (idle, state, status);
657 }
658
659 gboolean
660 empathy_idle_get_auto_away (EmpathyIdle *idle)
661 {
662         EmpathyIdlePriv *priv = GET_PRIV (idle);
663
664         return priv->auto_away;
665 }
666
667 void
668 empathy_idle_set_auto_away (EmpathyIdle *idle,
669                             gboolean     auto_away)
670 {
671         EmpathyIdlePriv *priv = GET_PRIV (idle);
672
673         priv->auto_away = auto_away;
674
675         g_object_notify (G_OBJECT (idle), "auto-away");
676 }
677
678 TpConnectionPresenceType
679 empathy_idle_get_requested_presence (EmpathyIdle *idle,
680     gchar **status,
681     gchar **status_message)
682 {
683         EmpathyIdlePriv *priv = GET_PRIV (idle);
684
685         if (status != NULL) {
686                 *status = g_strdup (presence_type_to_status[priv->requested_presence_type]);
687         }
688
689         if (status_message != NULL) {
690                 *status_message = g_strdup (priv->requested_status_message);
691         }
692
693         return priv->requested_presence_type;
694 }
695
696 /* This function returns %TRUE if EmpathyIdle considers the account
697  * @account as having just connected recently. Otherwise, it returns
698  * %FALSE. In doubt, %FALSE is returned. */
699 gboolean
700 empathy_idle_account_is_just_connected (EmpathyIdle *idle,
701                                         TpAccount *account)
702 {
703         EmpathyIdlePriv *priv = GET_PRIV (idle);
704         GTimeVal val;
705         gpointer ptr;
706         glong t;
707
708         if (tp_account_get_connection_status (account, NULL)
709             != TP_CONNECTION_STATUS_CONNECTED) {
710                 return FALSE;
711         }
712
713         ptr = g_hash_table_lookup (priv->connect_times, account);
714
715         if (ptr == NULL) {
716                 return FALSE;
717         }
718
719         t = GPOINTER_TO_INT (ptr);
720
721         g_get_current_time (&val);
722
723         return (val.tv_sec - t) < ACCOUNT_IS_JUST_CONNECTED_SECONDS;
724 }