Commit bd1a59c8 authored by Zeeshan Ali's avatar Zeeshan Ali

Add struct to represent a 3G tower

parent c0197f6a
......@@ -69,6 +69,7 @@ AM_CPPFLAGS = $(GEOCLUE_CFLAGS) \
libgeoclue_la_SOURCES = \
$(BUILT_SOURCES) \
gclue-3g-tower.h \
gclue-client-info.h \
gclue-client-info.c \
gclue-config.h \
......
/* vim: set et ts=8 sw=8: */
/*
* Copyright (C) 2014 Red Hat, Inc.
*
* Geoclue is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with Geoclue; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#ifndef GCLUE_3G_TOWER_H
#define GCLUE_3G_TOWER_H
G_BEGIN_DECLS
typedef struct _GClue3GTower GClue3GTower;
struct _GClue3GTower {
guint mcc;
guint mnc;
gulong lac;
gulong cell_id;
};
G_END_DECLS
#endif /* GCLUE_3G_TOWER_H */
......@@ -30,6 +30,7 @@
#define URL "http://www.opencellid.org/cell/get?mcc=%u&mnc=%u" \
"&lac=%lu&cellid=%lu&key=4f2d9207-1339-4718-a412-9683f1461de6"
#include "gclue-3g-tower.h"
/**
* SECTION:gclue-3g
......@@ -48,10 +49,7 @@ struct _GClue3GPrivate {
gulong threeg_notify_id;
guint mcc;
guint mnc;
gulong lac;
gulong cell_id;
GClue3GTower *tower;
};
G_DEFINE_TYPE (GClue3G, gclue_3g, GCLUE_TYPE_WEB_SOURCE)
......@@ -273,7 +271,7 @@ gclue_3g_create_query (GClueWebSource *web,
SoupMessage *ret = NULL;
char *uri;
if (priv->mcc == 0) {
if (priv->tower == NULL) {
g_set_error_literal (error,
G_IO_ERROR,
G_IO_ERROR_NOT_INITIALIZED,
......@@ -282,10 +280,10 @@ gclue_3g_create_query (GClueWebSource *web,
}
uri = g_strdup_printf (URL,
priv->mcc,
priv->mnc,
priv->lac,
priv->cell_id);
priv->tower->mcc,
priv->tower->mnc,
priv->tower->lac,
priv->tower->cell_id);
ret = soup_message_new ("GET", uri);
g_debug ("Will send request '%s'", uri);
......@@ -315,10 +313,12 @@ on_fix_3g (GClueModem *modem,
{
GClue3GPrivate *priv = GCLUE_3G (user_data)->priv;
priv->mcc = mcc;
priv->mnc = mnc;
priv->lac = lac;
priv->cell_id = cell_id;
if (priv->tower == NULL)
priv->tower = g_slice_new0 (GClue3GTower);
priv->tower->mcc = mcc;
priv->tower->mnc = mnc;
priv->tower->lac = lac;
priv->tower->cell_id = cell_id;
gclue_web_source_refresh (GCLUE_WEB_SOURCE (user_data));
}
......@@ -336,10 +336,10 @@ gclue_3g_start (GClueLocationSource *source)
if (!base_class->start (source))
return FALSE;
priv->mcc = 0;
priv->mnc = 0;
priv->lac = 0;
priv->cell_id = 0;
if (priv->tower != NULL) {
g_slice_free (GClue3GTower, priv->tower);
priv->tower = NULL;
}
g_signal_connect (priv->modem,
"fix-3g",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment