loudmouth/lm-feature-ping.c
changeset 725 05fa3e01e5b1
parent 690 7ccf2113ec5f
child 735 7ae46452fb10
equal deleted inserted replaced
724:3cd39dfd5ff7 725:05fa3e01e5b1
    26 
    26 
    27 #include "lm-feature-ping.h"
    27 #include "lm-feature-ping.h"
    28 
    28 
    29 #define XMPP_NS_PING "urn:xmpp:ping"
    29 #define XMPP_NS_PING "urn:xmpp:ping"
    30 
    30 
    31 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_FEATURE_PING, LmFeaturePingPriv))
    31 #define GET_PRIV(obj) (lm_feature_ping_get_instance_private (LM_FEATURE_PING(obj)))
    32 
    32 
    33 typedef struct LmFeaturePingPriv LmFeaturePingPriv;
    33 typedef struct LmFeaturePingPrivate LmFeaturePingPrivate;
    34 struct LmFeaturePingPriv {
    34 struct LmFeaturePingPrivate {
    35     LmConnection *connection;
    35     LmConnection *connection;
    36     guint         keep_alive_rate;
    36     guint         keep_alive_rate;
    37     GSource      *keep_alive_source;
    37     GSource      *keep_alive_source;
    38     guint         keep_alive_counter;
    38     guint         keep_alive_counter;
    39 };
    39 };
    53                                                   LmConnection     *connection,
    53                                                   LmConnection     *connection,
    54                                                   LmMessage        *m,
    54                                                   LmMessage        *m,
    55                                                   gpointer          user_data);
    55                                                   gpointer          user_data);
    56 static gboolean feature_ping_send_keep_alive     (LmFeaturePing    *fp);
    56 static gboolean feature_ping_send_keep_alive     (LmFeaturePing    *fp);
    57 
    57 
    58 G_DEFINE_TYPE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
    58 G_DEFINE_TYPE_WITH_PRIVATE (LmFeaturePing, lm_feature_ping, G_TYPE_OBJECT)
    59 
    59 
    60 enum {
    60 enum {
    61     PROP_0,
    61     PROP_0,
    62     PROP_CONNECTION,
    62     PROP_CONNECTION,
    63     PROP_RATE
    63     PROP_RATE
   101                       G_SIGNAL_RUN_LAST,
   101                       G_SIGNAL_RUN_LAST,
   102                       0,
   102                       0,
   103                       NULL, NULL,
   103                       NULL, NULL,
   104                       _lm_marshal_VOID__VOID,
   104                       _lm_marshal_VOID__VOID,
   105                       G_TYPE_NONE, 0);
   105                       G_TYPE_NONE, 0);
   106 
       
   107     g_type_class_add_private (object_class, sizeof (LmFeaturePingPriv));
       
   108 }
   106 }
   109 
   107 
   110 static void
   108 static void
   111 lm_feature_ping_init (LmFeaturePing *feature_ping)
   109 lm_feature_ping_init (LmFeaturePing *feature_ping)
   112 {
   110 {
   125 feature_ping_get_property (GObject    *object,
   123 feature_ping_get_property (GObject    *object,
   126                            guint       param_id,
   124                            guint       param_id,
   127                            GValue     *value,
   125                            GValue     *value,
   128                            GParamSpec *pspec)
   126                            GParamSpec *pspec)
   129 {
   127 {
   130     LmFeaturePingPriv *priv;
   128     LmFeaturePingPrivate *priv;
   131 
   129 
   132     priv = GET_PRIV (object);
   130     priv = GET_PRIV (object);
   133 
   131 
   134     switch (param_id) {
   132     switch (param_id) {
   135     case PROP_RATE:
   133     case PROP_RATE:
   145 feature_ping_set_property (GObject      *object,
   143 feature_ping_set_property (GObject      *object,
   146                            guint         param_id,
   144                            guint         param_id,
   147                            const GValue *value,
   145                            const GValue *value,
   148                            GParamSpec   *pspec)
   146                            GParamSpec   *pspec)
   149 {
   147 {
   150     LmFeaturePingPriv *priv;
   148     LmFeaturePingPrivate *priv;
   151 
   149 
   152     priv = GET_PRIV (object);
   150     priv = GET_PRIV (object);
   153 
   151 
   154     switch (param_id) {
   152     switch (param_id) {
   155     case PROP_CONNECTION:
   153     case PROP_CONNECTION:
   169 feature_ping_keep_alive_reply (LmMessageHandler *handler,
   167 feature_ping_keep_alive_reply (LmMessageHandler *handler,
   170                                LmConnection     *connection,
   168                                LmConnection     *connection,
   171                                LmMessage        *m,
   169                                LmMessage        *m,
   172                                gpointer          user_data)
   170                                gpointer          user_data)
   173 {
   171 {
   174     LmFeaturePingPriv *priv;
   172     LmFeaturePingPrivate *priv;
   175 
   173 
   176     priv = GET_PRIV (user_data);
   174     priv = GET_PRIV (user_data);
   177 
   175 
   178     priv->keep_alive_counter = 0;
   176     priv->keep_alive_counter = 0;
   179 
   177 
   181 }
   179 }
   182 
   180 
   183 static gboolean
   181 static gboolean
   184 feature_ping_send_keep_alive (LmFeaturePing *fp)
   182 feature_ping_send_keep_alive (LmFeaturePing *fp)
   185 {
   183 {
   186     LmFeaturePingPriv *priv;
   184     LmFeaturePingPrivate *priv;
   187     LmMessage         *ping;
   185     LmMessage         *ping;
   188     LmMessageNode     *ping_node;
   186     LmMessageNode     *ping_node;
   189     LmMessageHandler  *keep_alive_handler;
   187     LmMessageHandler  *keep_alive_handler;
   190     gchar             *server;
   188     gchar             *server;
   191 
   189 
   235 
   233 
   236 
   234 
   237 void
   235 void
   238 lm_feature_ping_start (LmFeaturePing *fp)
   236 lm_feature_ping_start (LmFeaturePing *fp)
   239 {
   237 {
   240     LmFeaturePingPriv *priv;
   238     LmFeaturePingPrivate *priv;
   241 
   239 
   242     g_return_if_fail (LM_IS_FEATURE_PING (fp));
   240     g_return_if_fail (LM_IS_FEATURE_PING (fp));
   243 
   241 
   244     priv = GET_PRIV (fp);
   242     priv = GET_PRIV (fp);
   245 
   243 
   258 }
   256 }
   259 
   257 
   260 void
   258 void
   261 lm_feature_ping_stop (LmFeaturePing *fp)
   259 lm_feature_ping_stop (LmFeaturePing *fp)
   262 {
   260 {
   263     LmFeaturePingPriv *priv;
   261     LmFeaturePingPrivate *priv;
   264 
   262 
   265     g_return_if_fail (LM_IS_FEATURE_PING (fp));
   263     g_return_if_fail (LM_IS_FEATURE_PING (fp));
   266 
   264 
   267     priv = GET_PRIV (fp);
   265     priv = GET_PRIV (fp);
   268 
   266