loudmouth/lm-feature-ping.c
author Mikael Berthe <mikael@lilotux.net>
Mon, 25 Jan 2016 18:35:10 +0100
changeset 685 dfa02c1c7fda
parent 624 a94013a4555d
child 690 7ccf2113ec5f
permissions -rw-r--r--
Bumped version to 1.5.2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
516
4dd3aa6b83e5 Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents: 515
diff changeset
     1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     2
/*
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     3
 * Copyright (C) 2008 Imendio AB
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     4
 *
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public License as
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     7
 * published by the Free Software Foundation; either version 2 of the
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     8
 * License, or (at your option) any later version.
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
     9
 *
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    13
 * Lesser General Public License for more details.
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    14
 *
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    16
 * License along with this program; if not, write to the
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    18
 * Boston, MA 02111-1307, USA.
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    19
 */
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    20
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    21
#include <config.h>
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    22
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    23
#include "lm-connection.h"
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    24
#include "lm-debug.h"
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    25
#include "lm-internals.h"
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    26
#include "lm-marshal.h"
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    27
#include "lm-misc.h"
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    28
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    29
#include "lm-feature-ping.h"
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    30
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    31
#define XMPP_NS_PING "urn:xmpp:ping"
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    32
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    33
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_FEATURE_PING, LmFeaturePingPriv))
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    34
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    35
typedef struct LmFeaturePingPriv LmFeaturePingPriv;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    36
struct LmFeaturePingPriv {
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    37
    LmConnection *connection;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    38
    guint         keep_alive_rate;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    39
    GSource      *keep_alive_source;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    40
    guint         keep_alive_counter;
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    41
};
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    42
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    43
static void     feature_ping_finalize            (GObject           *object);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    44
static void     feature_ping_get_property        (GObject           *object,
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    45
                                                  guint              param_id,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    46
                                                  GValue            *value,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    47
                                                  GParamSpec        *pspec);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    48
static void     feature_ping_set_property        (GObject           *object,
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    49
                                                  guint              param_id,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    50
                                                  const GValue      *value,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    51
                                                  GParamSpec        *pspec);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    52
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    53
static LmHandlerResult
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    54
feature_ping_keep_alive_reply                    (LmMessageHandler *handler,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    55
                                                  LmConnection     *connection,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    56
                                                  LmMessage        *m,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    57
                                                  gpointer          user_data);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    58
static gboolean feature_ping_send_keep_alive     (LmFeaturePing    *fp);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
    59
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    60
G_DEFINE_TYPE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    61
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    62
enum {
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    63
    PROP_0,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    64
    PROP_CONNECTION,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    65
    PROP_RATE
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    66
};
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    67
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    68
enum {
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    69
    TIMED_OUT,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    70
    LAST_SIGNAL
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    71
};
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    72
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    73
static guint signals[LAST_SIGNAL] = { 0 };
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    74
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    75
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    76
lm_feature_ping_class_init (LmFeaturePingClass *class)
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    77
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    78
    GObjectClass *object_class = G_OBJECT_CLASS (class);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    79
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    80
    object_class->finalize     = feature_ping_finalize;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    81
    object_class->get_property = feature_ping_get_property;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    82
    object_class->set_property = feature_ping_set_property;
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    83
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    84
    g_object_class_install_property (object_class,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    85
                                     PROP_CONNECTION,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    86
                                     g_param_spec_pointer ("connection",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    87
                                                           "Connection",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    88
                                                           "The LmConnection to use",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    89
                                                           G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    90
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    91
    g_object_class_install_property (object_class,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    92
                                     PROP_RATE,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    93
                                     g_param_spec_uint ("rate",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    94
                                                        "Timeout Rate",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    95
                                                        "Keep alive rate in seconds",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    96
                                                        0, G_MAXUINT,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    97
                                                        0,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    98
                                                        G_PARAM_READWRITE));
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    99
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 521
diff changeset
   100
    signals[TIMED_OUT] =
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   101
        g_signal_new ("timed-out",
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   102
                      G_OBJECT_CLASS_TYPE (object_class),
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   103
                      G_SIGNAL_RUN_LAST,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   104
                      0,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   105
                      NULL, NULL,
521
50294ce6587e Updated the build system to use a build directory and a common marshal Makefile.
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
   106
                      _lm_marshal_VOID__VOID,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   107
                      G_TYPE_NONE, 0);
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 521
diff changeset
   108
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   109
    g_type_class_add_private (object_class, sizeof (LmFeaturePingPriv));
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   110
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   111
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   112
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   113
lm_feature_ping_init (LmFeaturePing *feature_ping)
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   114
{
624
a94013a4555d Fix some gcc warnings
Mikael Berthe <mikael@lilotux.net>
parents: 621
diff changeset
   115
    (void) GET_PRIV (feature_ping);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   116
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   117
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   118
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   119
feature_ping_finalize (GObject *object)
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   120
{
624
a94013a4555d Fix some gcc warnings
Mikael Berthe <mikael@lilotux.net>
parents: 621
diff changeset
   121
    (void) GET_PRIV (object);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   122
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   123
    (G_OBJECT_CLASS (lm_feature_ping_parent_class)->finalize) (object);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   124
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   125
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   126
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   127
feature_ping_get_property (GObject    *object,
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   128
                           guint       param_id,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   129
                           GValue     *value,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   130
                           GParamSpec *pspec)
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   131
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   132
    LmFeaturePingPriv *priv;
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   133
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   134
    priv = GET_PRIV (object);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   135
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   136
    switch (param_id) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   137
    case PROP_RATE:
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   138
        g_value_set_uint (value, priv->keep_alive_rate);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   139
        break;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   140
    default:
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   141
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   142
        break;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   143
    };
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   144
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   145
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   146
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   147
feature_ping_set_property (GObject      *object,
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   148
                           guint         param_id,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   149
                           const GValue *value,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   150
                           GParamSpec   *pspec)
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   151
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   152
    LmFeaturePingPriv *priv;
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   153
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   154
    priv = GET_PRIV (object);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   155
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   156
    switch (param_id) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   157
    case PROP_CONNECTION:
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   158
        priv->connection = g_value_get_pointer (value);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   159
        break;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   160
    case PROP_RATE:
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   161
        priv->keep_alive_rate = g_value_get_uint (value);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   162
        /* Restart the pings */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   163
        break;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   164
    default:
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   165
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   166
        break;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   167
    };
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   168
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   169
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   170
static LmHandlerResult
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   171
feature_ping_keep_alive_reply (LmMessageHandler *handler,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   172
                               LmConnection     *connection,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   173
                               LmMessage        *m,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   174
                               gpointer          user_data)
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   175
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   176
    LmFeaturePingPriv *priv;
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   177
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   178
    priv = GET_PRIV (user_data);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   179
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   180
    priv->keep_alive_counter = 0;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 521
diff changeset
   181
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   182
    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   183
}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   184
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   185
static gboolean
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   186
feature_ping_send_keep_alive (LmFeaturePing *fp)
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   187
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   188
    LmFeaturePingPriv *priv;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   189
    LmMessage         *ping;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   190
    LmMessageNode     *ping_node;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   191
    LmMessageHandler  *keep_alive_handler;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   192
    gchar             *server;
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   193
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   194
    priv = GET_PRIV (fp);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   195
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   196
    priv->keep_alive_counter++;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   197
    if (priv->keep_alive_counter > 3) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   198
        g_signal_emit (fp, signals[TIMED_OUT], 0);
621
2313363bd272 Give up unneeded ping request on connection timeout
Hermitifier <quantifier666@gmail.com>
parents: 607
diff changeset
   199
       return FALSE;
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   200
        /* FIXME */
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   201
#if 0 /* Should be moved to signal callback in LmConnection */
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   202
        connection_do_close (connection);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   203
        connection_signal_disconnect (connection,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   204
                                      LM_DISCONNECT_REASON_PING_TIME_OUT);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   205
#endif
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   206
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   207
    }
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   208
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   209
    server = _lm_connection_get_server (priv->connection);
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 521
diff changeset
   210
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   211
    ping = lm_message_new_with_sub_type (server,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   212
                                         LM_MESSAGE_TYPE_IQ,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   213
                                         LM_MESSAGE_SUB_TYPE_GET);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   214
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   215
    ping_node = lm_message_node_add_child (ping->node, "ping", NULL);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   216
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   217
    lm_message_node_set_attribute (ping_node, "xmlns", XMPP_NS_PING);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   218
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   219
    keep_alive_handler =
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   220
        lm_message_handler_new (feature_ping_keep_alive_reply,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   221
                                fp,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   222
                                FALSE);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   223
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   224
    if (!lm_connection_send_with_reply (priv->connection,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   225
                                        ping,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   226
                                        keep_alive_handler,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   227
                                        NULL)) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   228
        lm_verbose ("Error while sending XMPP ping!\n");
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   229
    }
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   230
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   231
    lm_message_handler_unref (keep_alive_handler);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   232
    lm_message_unref (ping);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   233
    g_free (server);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   234
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   235
    return TRUE;
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   236
}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   237
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   238
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   239
void
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   240
lm_feature_ping_start (LmFeaturePing *fp)
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   241
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   242
    LmFeaturePingPriv *priv;
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   243
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   244
    g_return_if_fail (LM_IS_FEATURE_PING (fp));
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   245
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   246
    priv = GET_PRIV (fp);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   247
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   248
    if (priv->keep_alive_source) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   249
        lm_feature_ping_stop (fp);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   250
    }
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   251
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   252
    if (priv->keep_alive_rate > 0) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   253
        priv->keep_alive_counter = 0;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   254
        priv->keep_alive_source =
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   255
            lm_misc_add_timeout (_lm_connection_get_context (priv->connection),
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   256
                                 priv->keep_alive_rate * 1000,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   257
                                 (GSourceFunc) feature_ping_send_keep_alive,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   258
                                 fp);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   259
    }
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   260
}
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   261
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   262
void
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   263
lm_feature_ping_stop (LmFeaturePing *fp)
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   264
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   265
    LmFeaturePingPriv *priv;
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   266
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   267
    g_return_if_fail (LM_IS_FEATURE_PING (fp));
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   268
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   269
    priv = GET_PRIV (fp);
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   270
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   271
    if (priv->keep_alive_source) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   272
        g_source_destroy (priv->keep_alive_source);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   273
    }
507
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   274
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   275
    priv->keep_alive_source = NULL;
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   276
}
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   277
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   278