loudmouth/lm-feature-ping.c
author Mikael Hallendal <micke@imendio.com>
Wed, 08 Oct 2008 12:34:50 +0200
changeset 515 fb0f1adfa271
parent 509 497afdad39a5
child 516 4dd3aa6b83e5
permissions -rw-r--r--
Change the emacs format string to use space instead of tab for indentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
515
fb0f1adfa271 Change the emacs format string to use space instead of tab for indentation
Mikael Hallendal <micke@imendio.com>
parents: 509
diff changeset
     1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
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 {
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    37
        LmConnection *connection;
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    38
	guint         keep_alive_rate;
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    39
	GSource      *keep_alive_source;
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
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 {
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    63
	PROP_0,
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    64
        PROP_CONNECTION,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
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 {
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    69
        TIMED_OUT,
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    70
	LAST_SIGNAL
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
{
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    78
	GObjectClass *object_class = G_OBJECT_CLASS (class);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    79
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    80
	object_class->finalize     = feature_ping_finalize;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    81
	object_class->get_property = feature_ping_get_property;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    82
	object_class->set_property = feature_ping_set_property;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
    83
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    84
        g_object_class_install_property (object_class,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    85
                                         PROP_CONNECTION,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    86
                                         g_param_spec_pointer ("connection",
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    87
                                                               "Connection",
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    88
                                                               "The LmConnection to use",
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    89
                                                               G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    90
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    91
        g_object_class_install_property (object_class,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    92
					 PROP_RATE,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    93
					 g_param_spec_uint ("rate",
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    94
                                                            "Timeout Rate",
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    95
                                                            "Keep alive rate in seconds",
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    96
                                                            0, G_MAXUINT,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    97
                                                            0,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    98
                                                            G_PARAM_READWRITE));
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
    99
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   100
        signals[TIMED_OUT] = 
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   101
		g_signal_new ("timed-out",
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   102
			      G_OBJECT_CLASS_TYPE (object_class),
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   103
			      G_SIGNAL_RUN_LAST,
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   104
			      0,
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   105
			      NULL, NULL,
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   106
			      lm_marshal_VOID__VOID,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   107
			      G_TYPE_NONE, 0);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   108
	
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   109
	g_type_class_add_private (object_class, sizeof (LmFeaturePingPriv));
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
{
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   115
	LmFeaturePingPriv *priv;
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
	priv = GET_PRIV (feature_ping);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   118
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   119
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   120
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   121
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   122
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
   123
{
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   124
	LmFeaturePingPriv *priv;
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
	priv = GET_PRIV (object);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   127
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   128
	(G_OBJECT_CLASS (lm_feature_ping_parent_class)->finalize) (object);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   129
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   130
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   131
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   132
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
   133
                           guint       param_id,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   134
                           GValue     *value,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   135
                           GParamSpec *pspec)
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   136
{
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   137
	LmFeaturePingPriv *priv;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   138
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   139
	priv = GET_PRIV (object);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   140
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   141
	switch (param_id) {
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   142
	case PROP_RATE:
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   143
		g_value_set_uint (value, priv->keep_alive_rate);
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   144
		break;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   145
	default:
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   146
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   147
		break;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   148
	};
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   149
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   150
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   151
static void
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   152
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
   153
                           guint         param_id,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   154
                           const GValue *value,
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   155
                           GParamSpec   *pspec)
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   156
{
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   157
	LmFeaturePingPriv *priv;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   158
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   159
	priv = GET_PRIV (object);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   160
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   161
	switch (param_id) {
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   162
        case PROP_CONNECTION:
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   163
                priv->connection = g_value_get_pointer (value);
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   164
                break;
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   165
        case PROP_RATE:
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   166
		priv->keep_alive_rate = g_value_get_uint (value);
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   167
                /* Restart the pings */
505
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   168
		break;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   169
	default:
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   170
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   171
		break;
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   172
	};
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   173
}
ba6f96b3e4a8 Added stubs for LmFeaturePing which will hold the XMPP Ping feature.
Mikael Hallendal <micke@imendio.com>
parents:
diff changeset
   174
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
   175
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
   176
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
   177
                               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
   178
                               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
   179
                               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
   180
{
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   181
        LmFeaturePingPriv *priv;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   182
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
        priv = GET_PRIV (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
   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
        priv->keep_alive_counter = 0;
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
	
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
        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   188
}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   189
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   190
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
   191
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
   192
{
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
        LmFeaturePingPriv *priv;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   194
	LmMessage         *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
   195
        LmMessageNode     *ping_node;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   196
	LmMessageHandler  *keep_alive_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
   197
        gchar             *server;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   198
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   199
        priv = GET_PRIV (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
   200
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
        priv->keep_alive_counter++;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   202
	if (priv->keep_alive_counter > 3) {
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   203
                g_signal_emit (fp, signals[TIMED_OUT], 0);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   204
                /* FIXME */
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
#if 0 /* Should be moved to signal callback in LmConnection */
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
                connection_do_close (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
   207
		connection_signal_disconnect (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
   208
					      LM_DISCONNECT_REASON_PING_TIME_OUT);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   209
#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
   210
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   211
	}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   212
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   213
        server = _lm_connection_get_server (priv->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
   214
	
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   215
        ping = lm_message_new_with_sub_type (server,
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
					     LM_MESSAGE_TYPE_IQ,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   217
					     LM_MESSAGE_SUB_TYPE_GET);
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
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   219
	ping_node = lm_message_node_add_child (ping->node, "ping", NULL);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   220
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   221
	lm_message_node_set_attribute (ping_node, "xmlns", XMPP_NS_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
   222
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
	keep_alive_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
   224
		lm_message_handler_new (feature_ping_keep_alive_reply,
509
497afdad39a5 Fixed a crash LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 507
diff changeset
   225
                                        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
   226
				        FALSE);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   227
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   228
        if (!lm_connection_send_with_reply (priv->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
   229
					    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
   230
					    keep_alive_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
   231
					    NULL)) {
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   232
                lm_verbose ("Error while sending XMPP ping!\n");
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   233
	}
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
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   235
	lm_message_handler_unref (keep_alive_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
   236
	lm_message_unref (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
   237
	g_free (server);
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
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   239
	return TRUE;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   240
}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   241
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   242
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   243
void
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   244
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
   245
{
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
   246
        LmFeaturePingPriv *priv;
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
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   248
        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
   249
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   250
        priv = GET_PRIV (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
   251
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   252
        if (priv->keep_alive_source) {
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   253
                lm_feature_ping_stop (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
   254
	}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   255
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   256
        if (priv->keep_alive_rate > 0) {
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   257
                priv->keep_alive_counter = 0;
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   258
                priv->keep_alive_source =
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   259
                        lm_misc_add_timeout (_lm_connection_get_context (priv->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
   260
					     priv->keep_alive_rate * 1000,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   261
					     (GSourceFunc) feature_ping_send_keep_alive,
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   262
                                             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
   263
	}
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   264
}
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   265
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   266
void
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   267
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
   268
{
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
   269
        LmFeaturePingPriv *priv;
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
506
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   271
        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
   272
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   273
        priv = GET_PRIV (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
   274
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   275
        if (priv->keep_alive_source) {
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   276
		g_source_destroy (priv->keep_alive_source);
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   277
	}
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   278
06e7b24dbcb3 Added the code from LmConnection to send and receive the XMPP Ping to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 506
diff changeset
   279
        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
   280
}
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   281
9d9be7000667 Added properties, signals and start/stop calls to LmFeaturePing.
Mikael Hallendal <micke@imendio.com>
parents: 505
diff changeset
   282