Skip to content

Commit

Permalink
Removed getlocation command as we no longer fit into their usage policy.
Browse files Browse the repository at this point in the history
Fixes #172

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Aug 23, 2016
1 parent 3f3dda9 commit eb027b0
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 147 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,6 @@ set (DOCS
COPYING
)

# OpenCellID API key
set (OPENCELLID_API_KEY "2623b0e70e9fa77754a3db53f3cb6458" CACHE STRING "OpenCellID API key")
mark_as_advanced (OPENCELLID_API_KEY)

if (CMAKE_USE_PTHREADS_INIT)
set (HAVE_PTHREAD ON)
endif (CMAKE_USE_PTHREADS_INIT)
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ChangeLog
[-] * Fixed various Windows compilation issues.
[-] * Fixed several resource leaks.
[-] * Create outbox SMS atomically in FILES backend.
[!] * Removed getlocation command as we no longer fit into their usage policy.

20160816 - 1.37.4

Expand Down
3 changes: 0 additions & 3 deletions cmake/templates/gammu-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,6 @@
/* Path where locales will be installed */
#define GAMMU_DATA_PATH "@CMAKE_INSTALL_PREFIX@/@INSTALL_DATA_DIR@"

/* OpenCellID API key */
#define OPENCELLID_API_KEY "@OPENCELLID_API_KEY@"

/* Most winapi crap can be used as well from Cygwin */
#if defined(WIN32) || defined(__CYGWIN__)
#define HAVE_WINDOWS_SERVICE
Expand Down
6 changes: 0 additions & 6 deletions docs/manual/gammu/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1466,12 +1466,6 @@ Phone information commands

.. option:: getdisplaystatus

.. option:: getlocation

Gets network information from phone (same as networkinfo)
and prints location (latitude and longitude) based on information from
`OpenCellID <http://opencellid.org>`_.

.. option:: getsecuritystatus

Show, if phone wait for security code (like PIN, PUK, etc.) or not
Expand Down
5 changes: 2 additions & 3 deletions docs/manual/project/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6AE02498
Dependencies
------------

You need CMake from <http://www.cmake.org/> for compiling Gammu.
You need CMake from <https://cmake.org/> for compiling Gammu.

Additionally pkg-config <http://pkg-config.freedesktop.org/> is used for
detecting available libraries.
Expand Down Expand Up @@ -80,8 +80,7 @@ Required for fbususb/dku2 connection support on Linux.
libCURL
+++++++

Required for new versions notification (see :option:`gammu checkversion`) and
OpenCellID access (see :option:`gammu getlocation`).
Required for new versions notification (see :option:`gammu checkversion`).

.. seealso:: http://curl.haxx.se/libcurl/

Expand Down
3 changes: 0 additions & 3 deletions gammu/CMakeTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ gammu_test_fail(getwapbookmark "Entry is empty" 3)

if (ONLINE_TESTING AND CURL_FOUND)
gammu_test(checkversion "")

# Seems to be broken now
# gammu_test(getlocation "Number of samples;Could not connect to the server;Could not resolve the host name")
endif (ONLINE_TESTING AND CURL_FOUND)

# MMS decoding
Expand Down
1 change: 0 additions & 1 deletion gammu/gammu.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ static GSM_Parameters Parameters[] = {
{"features", 0, 0, Features, {H_Gammu,0}, ""},
{"checkversion", 0, 1, CheckVersion, {H_Gammu,0}, "[STABLE]"},
{"getdisplaystatus", 0, 0, GetDisplayStatus, {H_Info,0}, ""},
{"getlocation", 0, 0, GetLocation, {H_Info,0}, ""},
{"monitor", 0, 1, Monitor, {H_Info,H_Network,H_Call,0}, "[times]"},
{"battery", 0, 0, Battery, {H_Info,0}, ""},
{"setautonetworklogin", 0, 0, SetAutoNetworkLogin, {H_Network,0}, ""},
Expand Down
127 changes: 0 additions & 127 deletions gammu/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,133 +236,6 @@ void PlayRingtone(int argc UNUSED, char *argv[])
GSM_Terminate();
}

/**
* Get's location from OpenCellID.
*/
void GetLocation(int argc UNUSED, char *argv[]UNUSED)
{
GSM_File OpenCell;
char url[70 + GSM_MAX_MODEL_LENGTH];
char *pos;
GSM_Error error;
GSM_NetworkInfo netinfo;
float latitude, longitude;
long int mnc, mcc, lac, cellid, nbSamples, range;
char *ret, *old_locale = NULL;
gboolean failure = FALSE;

GSM_Init(TRUE);

/* Get model information */
error = GSM_GetNetworkInfo(gsm, &netinfo);
Print_Error(error);

if (netinfo.State == GSM_NoNetwork) {
printf_err("%s", _("Not logged to network!\n"));
GSM_Terminate();
return;
}

/* We need decimal numbers */
lac = strtol(netinfo.LAC, NULL, 16);
cellid = strtol(netinfo.CID, NULL, 16);

/* Split code to country and network (beware ncc+nmc without space) */
if (sscanf(netinfo.NetworkCode, "%3ld%ld", &mcc, &mnc) != 2) {
printf_err("%s", _("Wrong network code from phone!\n"));
GSM_Terminate();
return;
}

/* Request information from OpenCellID */
sprintf(url, "http://www.opencellid.org/cell/get?key=%s&mnc=%ld&mcc=%ld&lac=%ld&cellid=%ld",
OPENCELLID_API_KEY,
mnc, mcc, lac, cellid);

OpenCell.Buffer = NULL;
OpenCell.Used = 0;
error = GSM_ReadHTTPFile(url, &OpenCell);
Print_Error(error);

/* We need to reset numeric locales because we parse floats with . as decimal separator */
ret = setlocale(LC_NUMERIC, "C");
if (ret != NULL) {
old_locale = strdup(ret);
}

/* Parse reply:
<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok">
<cell range="6000" lac="0" lat="54.4910893937777" nbSamples="46" lon="27.9390742994699" cellId="29513" mcc="250" mnc="99"/>
</rsp>
*/
if (strstr(OpenCell.Buffer, "stat=\"ok\"") == NULL) {
printf_err("%s", _("Request for information from OpenCellID failed!\n"));
failure = TRUE;
goto done;
}
pos = strstr(OpenCell.Buffer, "lat=\"");
if (pos == NULL) {
printf_err("%s", _("Failed to find latitude in OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
if (sscanf(pos, "lat=\"%f\"", &latitude) == 0) {
printf_err("%s", _("Failed to parse latitude from OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
pos = strstr(OpenCell.Buffer, "lon=\"");
if (pos == NULL) {
printf_err("%s", _("Failed to find longitude in OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
if (sscanf(pos, "lon=\"%f\"", &longitude) == 0) {
printf_err("%s", _("Failed to parse longitude from OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
pos = strstr(OpenCell.Buffer, "range=\"");
if (pos == NULL) {
printf_err("%s", _("Failed to find range in OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
if (sscanf(pos, "range=\"%ld\"", &range) == 0) {
printf_err("%s", _("Failed to parse range from OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
pos = strstr(OpenCell.Buffer, "nbSamples=\"");
if (pos == NULL) {
printf_err("%s", _("Failed to find nbSamples in OpenCellID reply!\n"));
failure = TRUE;
goto done;
}
if (sscanf(pos, "nbSamples=\"%ld\"", &nbSamples) == 0) {
printf_err("%s", _("Failed to parse nbSamples from OpenCellID reply!\n"));
failure = TRUE;
goto done;
}

done:
if (old_locale != NULL) {
setlocale(LC_NUMERIC, old_locale);
free(old_locale);
}
if (!failure) {
printf(LISTFORMAT "%f\n", _("Latitude"), latitude);
printf(LISTFORMAT "%f\n", _("Longitude"), longitude);
printf(LISTFORMAT "%ld\n", _("Range"), range);
printf(LISTFORMAT "%ld\n", _("Number of samples"), nbSamples);
}

free(OpenCell.Buffer);
GSM_Terminate();
}



void Identify(int argc, char *argv[])
{
Expand Down

0 comments on commit eb027b0

Please sign in to comment.