core: start using our newly defined errors

This commit is contained in:
Aleksander Morgado
2011-11-23 12:36:47 +01:00
parent e4d8c4ace7
commit c58db4e015
23 changed files with 414 additions and 731 deletions

View File

@@ -28,7 +28,6 @@
#include "mm-plugin-generic.h"
#include "mm-broadband-modem.h"
#include "mm-errors.h"
#include "mm-serial-parsers.h"
#include "mm-log.h"

View File

@@ -24,8 +24,8 @@ libmodem_helpers_la_LIBADD = \
$(top_builddir)/libmm-common/libmm-common.la
libmodem_helpers_la_SOURCES = \
mm-errors.c \
mm-errors.h \
mm-error-helpers.c \
mm-error-helpers.h \
mm-modem-helpers.c \
mm-modem-helpers.h \
mm-charsets.c \

View File

@@ -22,7 +22,6 @@
#include <string.h>
#include "mm-at-serial-port.h"
#include "mm-errors.h"
#include "mm-log.h"
G_DEFINE_TYPE (MMAtSerialPort, mm_at_serial_port, MM_TYPE_SERIAL_PORT)

View File

@@ -22,13 +22,11 @@
#include <string.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include <mm-gdbus-modem.h>
#include "mm-base-modem.h"
#include "mm-errors.h"
#include "mm-log.h"
#include "mm-at-serial-port.h"
#include "mm-qcdm-serial-port.h"

View File

@@ -22,7 +22,6 @@
#include <string.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include <mm-enums-types.h>
@@ -30,7 +29,6 @@
#include "mm-broadband-modem.h"
#include "mm-iface-modem.h"
#include "mm-sim.h"
#include "mm-errors.h"
#include "mm-log.h"
#include "mm-modem-helpers.h"

View File

@@ -15,7 +15,9 @@
*/
#include "mm-callback-info.h"
#include "mm-errors.h"
#include <ModemManager.h>
#include <mm-errors-types.h>
#define CALLBACK_INFO_RESULT "callback-info-result"
@@ -68,8 +70,8 @@ modem_destroyed_cb (gpointer data, GObject *destroyed)
/* Overwrite any possible previous error set */
g_clear_error (&(info->error));
info->error = g_error_new_literal (MM_MODEM_ERROR,
MM_MODEM_ERROR_REMOVED,
info->error = g_error_new_literal (MM_CORE_ERROR,
MM_CORE_ERROR_ABORTED,
"The modem was removed.");
/* Only schedule the info if not already done before */

267
src/mm-error-helpers.c Normal file
View File

@@ -0,0 +1,267 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program 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.
*
* This program 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:
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 - 2012 Red Hat, Inc.
* Copyright (C) 2011 - 2012 Google, Inc.
*/
#include "mm-error-helpers.h"
#include <ctype.h>
typedef struct {
guint code;
const gchar *error; /* lowercase, and stripped of special chars and whitespace */
const gchar *message;
} ErrorTable;
/* --- Connection errors --- */
GError *
mm_connection_error_for_code (MMConnectionError code)
{
const gchar *msg;
switch (code) {
case MM_CONNECTION_ERROR_UNKNOWN:
msg = "Unknown";
break;
case MM_CONNECTION_ERROR_NO_CARRIER:
msg = "No carrier";
break;
case MM_CONNECTION_ERROR_NO_DIALTONE:
msg = "No dialtone";
break;
case MM_CONNECTION_ERROR_BUSY:
msg = "Busy";
break;
case MM_CONNECTION_ERROR_NO_ANSWER:
msg = "No answer";
break;
default:
g_warning ("Invalid connection error code: %u", code);
/* uhm... make something up (yes, ok, lie!). */
code = MM_CONNECTION_ERROR_NO_CARRIER;
msg = "No carrier";
}
return g_error_new_literal (MM_CONNECTION_ERROR, code, msg);
}
/* --- Mobile equipment errors --- */
static ErrorTable me_errors[] = {
{ MM_MOBILE_EQUIPMENT_ERROR_PHONE_FAILURE, "phonefailure", "Phone failure" },
{ MM_MOBILE_EQUIPMENT_ERROR_NO_CONNECTION, "noconnectiontophone", "No connection to phone" },
{ MM_MOBILE_EQUIPMENT_ERROR_LINK_RESERVED, "phoneadapterlinkreserved", "Phone-adaptor link reserved" },
{ MM_MOBILE_EQUIPMENT_ERROR_NOT_ALLOWED, "operationnotallowed", "Operation not allowed" },
{ MM_MOBILE_EQUIPMENT_ERROR_NOT_SUPPORTED, "operationnotsupported", "Operation not supported" },
{ MM_MOBILE_EQUIPMENT_ERROR_PH_SIM_PIN, "phsimpinrequired", "PH-SIM PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_PH_FSIM_PIN, "phfsimpinrequired", "PH-FSIM PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_PH_FSIM_PUK, "phfsimpukrequired", "PH-FSIM PUK required" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED, "simnotinserted", "SIM not inserted" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_PIN, "simpinrequired", "SIM PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_PUK, "simpukrequired", "SIM PUK required" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_FAILURE, "simfailure", "SIM failure" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_BUSY, "simbusy", "SIM busy" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG, "simwrong", "SIM wrong" },
{ MM_MOBILE_EQUIPMENT_ERROR_INCORRECT_PASSWORD, "incorrectpassword", "Incorrect password" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_PIN2, "simpin2required", "SIM PIN2 required" },
{ MM_MOBILE_EQUIPMENT_ERROR_SIM_PUK2, "simpuk2required", "SIM PUK2 required" },
{ MM_MOBILE_EQUIPMENT_ERROR_MEMORY_FULL, "memoryfull", "Memory full" },
{ MM_MOBILE_EQUIPMENT_ERROR_INVALID_INDEX, "invalidindex", "Invalid index" },
{ MM_MOBILE_EQUIPMENT_ERROR_NOT_FOUND, "notfound", "Not found" },
{ MM_MOBILE_EQUIPMENT_ERROR_MEMORY_FAILURE, "memoryfailure", "Memory failure" },
{ MM_MOBILE_EQUIPMENT_ERROR_TEXT_TOO_LONG, "textstringtoolong", "Text string too long" },
{ MM_MOBILE_EQUIPMENT_ERROR_INVALID_CHARS, "invalidcharactersintextstring", "Invalid characters in text string" },
{ MM_MOBILE_EQUIPMENT_ERROR_DIAL_STRING_TOO_LONG, "dialstringtoolong", "Dial string too long" },
{ MM_MOBILE_EQUIPMENT_ERROR_DIAL_STRING_INVALID, "invalidcharactersindialstring", "Invalid characters in dial string" },
{ MM_MOBILE_EQUIPMENT_ERROR_NO_NETWORK, "nonetworkservice", "No network service" },
{ MM_MOBILE_EQUIPMENT_ERROR_NETWORK_TIMEOUT, "networktimeout", "Network timeout" },
{ MM_MOBILE_EQUIPMENT_ERROR_NETWORK_NOT_ALLOWED, "networknotallowedemergencycallsonly", "Network not allowed - emergency calls only" },
{ MM_MOBILE_EQUIPMENT_ERROR_NETWORK_PIN, "networkpersonalizationpinrequired", "Network personalization PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_NETWORK_PUK, "networkpersonalizationpukrequired", "Network personalization PUK required" },
{ MM_MOBILE_EQUIPMENT_ERROR_NETWORK_SUBSET_PIN, "networksubsetpersonalizationpinrequired", "Network subset personalization PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_NETWORK_SUBSET_PUK, "networksubsetpersonalizationpukrequired", "Network subset personalization PUK required" },
{ MM_MOBILE_EQUIPMENT_ERROR_SERVICE_PIN, "serviceproviderpersonalizationpinrequired", "Service provider personalization PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_SERVICE_PUK, "serviceproviderpersonalizationpukrequired", "Service provider personalization PUK required" },
{ MM_MOBILE_EQUIPMENT_ERROR_CORP_PIN, "corporatepersonalizationpinrequired", "Corporate personalization PIN required" },
{ MM_MOBILE_EQUIPMENT_ERROR_CORP_PUK, "corporatepersonalizationpukrequired", "Corporate personalization PUK required" },
{ MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN, "unknownerror", "Unknown error" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_ILLEGAL_MS, "illegalms", "Illegal MS" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_ILLEGAL_ME, "illegalme", "Illegal ME" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_NOT_ALLOWED, "gprsservicesnotallowed", "GPRS services not allowed" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_PLMN_NOT_ALLOWED, "plmnnotallowed", "PLMN not allowed" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_LOCATION_NOT_ALLOWED, "locationareanotallowed", "Location area not allowed" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_ROAMING_NOT_ALLOWED, "roamingnotallowedinthislocationarea", "Roaming not allowed in this location area" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_OPTION_NOT_SUPPORTED, "serviceoperationnotsupported", "Service option not supported" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_OPTION_NOT_SUBSCRIBED, "requestedserviceoptionnotsubscribed", "Requested service option not subscribed" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_SERVICE_OPTION_OUT_OF_ORDER, "serviceoptiontemporarilyoutoforder", "Service option temporarily out of order" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_UNKNOWN, "unspecifiedgprserror", "Unspecified GPRS error" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_PDP_AUTH_FAILURE, "pdpauthenticationfailure", "PDP authentication failure" },
{ MM_MOBILE_EQUIPMENT_ERROR_GPRS_INVALID_MOBILE_CLASS, "invalidmobileclass", "Invalid mobile class" },
};
GError *
mm_mobile_equipment_error_for_code (MMMobileEquipmentError code)
{
const gchar *msg = NULL;
guint i;
/* Look for the code */
for (i = 0; i < G_N_ELEMENTS (me_errors); i++) {
if (me_errors[i].code == code) {
msg = me_errors[i].message;
break;
}
}
/* Not found? Then, default */
if (!msg) {
g_warning ("Invalid mobile equipment error code: %d", code);
code = MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN;
msg = "Unknown error";
}
return g_error_new_literal (MM_MOBILE_EQUIPMENT_ERROR, code, msg);
}
GError *
mm_mobile_equipment_error_for_string (const gchar *str)
{
MMMobileEquipmentError code = MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN;
const gchar *msg = NULL;
gchar *buf;
guint i;
guint j;
g_return_val_if_fail (str != NULL, NULL);
/* Normalize the error code by stripping whitespace and odd characters */
buf = g_strdup (str);
for (i = 0, j = 0; str[i]; i++) {
if (isalnum (str[i]))
buf[j++] = tolower (str[i]);
}
buf[j] = '\0';
/* Look for the string */
for (i = 0; i < G_N_ELEMENTS (me_errors); i++) {
if (g_str_equal (me_errors[i].error, buf)) {
code = me_errors[i].code;
msg = me_errors[i].message;
break;
}
}
/* Not found? Then, default */
if (!msg) {
g_warning ("Invalid mobile equipment error string: '%s' (%s)",
str, buf);
code = MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN;
msg = "Unknown error";
}
g_free (buf);
return g_error_new_literal (MM_MOBILE_EQUIPMENT_ERROR, code, msg);
}
/* --- Message errors --- */
static ErrorTable msg_errors[] = {
{ MM_MESSAGE_ERROR_ME_FAILURE, "mefailure", "ME failure" },
{ MM_MESSAGE_ERROR_SMS_SERVICE_RESERVED, "smsservicereserved", "SMS service reserved" },
{ MM_MESSAGE_ERROR_NOT_ALLOWED, "operationnotallowed", "Operation not allowed" },
{ MM_MESSAGE_ERROR_NOT_SUPPORTED, "operationnotsupported", "Operation not supported" },
{ MM_MESSAGE_ERROR_INVALID_PDU_PARAMETER, "invalidpduparameter", "Invalid PDU mode parameter" },
{ MM_MESSAGE_ERROR_INVALID_TEXT_PARAMETER, "invalidtextparameter", "Invalid text mode parameter" },
{ MM_MESSAGE_ERROR_SIM_NOT_INSERTED, "simnotinserted", "SIM not inserted" },
{ MM_MESSAGE_ERROR_SIM_PIN, "simpinrequired", "SIM PIN required" },
{ MM_MESSAGE_ERROR_PH_SIM_PIN, "phsimpinrequired", "PH-SIM PIN required" },
{ MM_MESSAGE_ERROR_SIM_FAILURE, "simfailure", "SIM failure" },
{ MM_MESSAGE_ERROR_SIM_BUSY, "simbusy", "SIM busy" },
{ MM_MESSAGE_ERROR_SIM_WRONG, "simwrong", "SIM wrong" },
{ MM_MESSAGE_ERROR_SIM_PUK, "simpukrequired", "SIM PUK required" },
{ MM_MESSAGE_ERROR_SIM_PIN2, "simpin2required", "SIM PIN2 required" },
{ MM_MESSAGE_ERROR_SIM_PUK2, "simpuk2required", "SIM PUK2 required" },
{ MM_MESSAGE_ERROR_MEMORY_FAILURE, "memoryfailure", "Memory failure" },
{ MM_MESSAGE_ERROR_INVALID_INDEX, "invalidindex", "Invalid index" },
{ MM_MESSAGE_ERROR_MEMORY_FULL, "memoryfull", "Memory full" },
{ MM_MESSAGE_ERROR_SMSC_ADDRESS_UNKNOWN, "smscaddressunknown", "SMSC address unknown" },
{ MM_MESSAGE_ERROR_NO_NETWORK, "nonetwork", "No network" },
{ MM_MESSAGE_ERROR_NETWORK_TIMEOUT, "networktimeout", "Network timeout" },
{ MM_MESSAGE_ERROR_NO_CNMA_ACK_EXPECTED, "nocnmaackexpected", "No CNMA acknowledgement expected" },
{ MM_MESSAGE_ERROR_UNKNOWN, "unknown", "Unknown" },
{ -1, NULL, NULL }
};
GError *
mm_message_error_for_code (MMMessageError code)
{
guint i;
/* Look for the code */
for (i = 0; i < G_N_ELEMENTS (msg_errors); i++) {
if (msg_errors[i].code == code)
return g_error_new_literal (MM_MESSAGE_ERROR,
code,
msg_errors[i].message);
}
/* Not found? Then, default */
g_warning ("Invalid message error code: %u", (guint)code);
return g_error_new (MM_MESSAGE_ERROR,
MM_MESSAGE_ERROR_UNKNOWN,
"Unknown error");
}
GError *
mm_message_error_for_string (const gchar *str)
{
MMMessageError code = MM_MESSAGE_ERROR_UNKNOWN;
const gchar *msg = NULL;
gchar *buf;
guint i;
guint j;
g_return_val_if_fail (str != NULL, NULL);
/* Normalize the error code by stripping whitespace and odd characters */
buf = g_strdup (str);
for (i = 0, j = 0; str[i]; i++) {
if (isalnum (str[i]))
buf[j++] = tolower (str[i]);
}
buf[j] = '\0';
/* Look for the string */
for (i = 0; i < G_N_ELEMENTS (msg_errors); i++) {
if (g_str_equal (msg_errors[i].error, buf)) {
code = msg_errors[i].code;
msg = msg_errors[i].message;
break;
}
}
/* Not found? Then, default */
if (!msg) {
g_warning ("Invalid message error string: '%s' (%s)",
str, buf);
code = MM_MESSAGE_ERROR_UNKNOWN;
msg = "Unknown error";
}
g_free (buf);
return g_error_new_literal (MM_MESSAGE_ERROR, code, msg);
}

32
src/mm-error-helpers.h Normal file
View File

@@ -0,0 +1,32 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program 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.
*
* This program 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:
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 - 2012 Red Hat, Inc.
* Copyright (C) 2011 - 2012 Google, Inc.
*/
#ifndef MM_ERROR_HELPERS_H
#define MM_ERROR_HELPERS_H
#include <glib-object.h>
#include <ModemManager-errors.h>
#include <mm-errors-types.h>
GError *mm_connection_error_for_code (MMConnectionError code);
GError *mm_mobile_equipment_error_for_code (MMMobileEquipmentError code);
GError *mm_mobile_equipment_error_for_string (const gchar *str);
GError *mm_message_error_for_code (MMMessageError code);
GError *mm_message_error_for_string (const gchar *str);
#endif /* MM_ERROR_HELPERS_H */

View File

@@ -1,463 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program 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.
*
* This program 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:
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 - 2010 Red Hat, Inc.
*/
#include "mm-errors.h"
#include <string.h>
#include <ctype.h>
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
GQuark
mm_modem_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0)
ret = g_quark_from_static_string ("mm_modem_error");
return ret;
}
GType
mm_modem_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (MM_MODEM_ERROR_GENERAL, "General"),
ENUM_ENTRY (MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED, "OperationNotSupported"),
ENUM_ENTRY (MM_MODEM_ERROR_CONNECTED, "Connected"),
ENUM_ENTRY (MM_MODEM_ERROR_DISCONNECTED, "Disconnected"),
ENUM_ENTRY (MM_MODEM_ERROR_OPERATION_IN_PROGRESS, "OperationInProgress"),
ENUM_ENTRY (MM_MODEM_ERROR_REMOVED, "Removed"),
ENUM_ENTRY (MM_MODEM_ERROR_AUTHORIZATION_REQUIRED, "AuthorizationRequired"),
ENUM_ENTRY (MM_MODEM_ERROR_UNSUPPORTED_CHARSET, "UnsupportedCharset"),
{ 0, 0, 0 }
};
etype = g_enum_register_static ("MMModemError", values);
}
return etype;
}
GQuark
mm_modem_connect_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0)
ret = g_quark_from_static_string ("mm_modem_connect_error");
return ret;
}
GType
mm_modem_connect_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (MM_MODEM_CONNECT_ERROR_NO_CARRIER, "NoCarrier"),
ENUM_ENTRY (MM_MODEM_CONNECT_ERROR_NO_DIALTONE, "NoDialtone"),
ENUM_ENTRY (MM_MODEM_CONNECT_ERROR_BUSY, "Busy"),
ENUM_ENTRY (MM_MODEM_CONNECT_ERROR_NO_ANSWER, "NoAnswer"),
{ 0, 0, 0 }
};
etype = g_enum_register_static ("MMModemConnectError", values);
}
return etype;
}
GError *
mm_modem_connect_error_for_code (int error_code)
{
const char *msg;
switch (error_code) {
case MM_MODEM_CONNECT_ERROR_NO_CARRIER:
msg = "No carrier";
break;
case MM_MODEM_CONNECT_ERROR_NO_DIALTONE:
msg = "No dialtone";
break;
case MM_MODEM_CONNECT_ERROR_BUSY:
msg = "Busy";
break;
case MM_MODEM_CONNECT_ERROR_NO_ANSWER:
msg = "No answer";
break;
default:
g_warning ("Invalid error code");
/* uhm... make something up (yes, ok, lie!). */
error_code = MM_MODEM_CONNECT_ERROR_NO_CARRIER;
msg = "No carrier";
}
return g_error_new_literal (MM_MODEM_CONNECT_ERROR, error_code, msg);
}
GQuark
mm_mobile_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0)
ret = g_quark_from_static_string ("mm_mobile_error");
return ret;
}
GType
mm_mobile_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (MM_MOBILE_ERROR_PHONE_FAILURE, "PhoneFailure"),
ENUM_ENTRY (MM_MOBILE_ERROR_NO_CONNECTION, "NoConnection"),
ENUM_ENTRY (MM_MOBILE_ERROR_LINK_RESERVED, "LinkReserved"),
ENUM_ENTRY (MM_MOBILE_ERROR_NOT_ALLOWED, "OperationNotAllowed"),
ENUM_ENTRY (MM_MOBILE_ERROR_NOT_SUPPORTED, "OperationNotSupported"),
ENUM_ENTRY (MM_MOBILE_ERROR_PH_SIM_PIN, "PhSimPinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_PH_FSIM_PIN, "PhFSimPinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_PH_FSIM_PUK, "PhFSimPukRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_NOT_INSERTED, "SimNotInserted"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_PIN, "SimPinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_PUK, "SimPukRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_FAILURE, "SimFailure"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_BUSY, "SimBusy"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_WRONG, "SimWrong"),
ENUM_ENTRY (MM_MOBILE_ERROR_WRONG_PASSWORD, "IncorrectPassword"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_PIN2, "SimPin2Required"),
ENUM_ENTRY (MM_MOBILE_ERROR_SIM_PUK2, "SimPuk2Required"),
ENUM_ENTRY (MM_MOBILE_ERROR_MEMORY_FULL, "MemoryFull"),
ENUM_ENTRY (MM_MOBILE_ERROR_INVALID_INDEX, "InvalidIndex"),
ENUM_ENTRY (MM_MOBILE_ERROR_NOT_FOUND, "NotFound"),
ENUM_ENTRY (MM_MOBILE_ERROR_MEMORY_FAILURE, "MemoryFailure"),
ENUM_ENTRY (MM_MOBILE_ERROR_TEXT_TOO_LONG, "TextTooLong"),
ENUM_ENTRY (MM_MOBILE_ERROR_INVALID_CHARS, "InvalidChars"),
ENUM_ENTRY (MM_MOBILE_ERROR_DIAL_STRING_TOO_LONG, "DialStringTooLong"),
ENUM_ENTRY (MM_MOBILE_ERROR_DIAL_STRING_INVALID, "InvalidDialString"),
ENUM_ENTRY (MM_MOBILE_ERROR_NO_NETWORK, "NoNetwork"),
ENUM_ENTRY (MM_MOBILE_ERROR_NETWORK_TIMEOUT, "NetworkTimeout"),
ENUM_ENTRY (MM_MOBILE_ERROR_NETWORK_NOT_ALLOWED, "NetworkNotAllowed"),
ENUM_ENTRY (MM_MOBILE_ERROR_NETWORK_PIN, "NetworkPinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_NETWORK_PUK, "NetworkPukRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_NETWORK_SUBSET_PIN, "NetworkSubsetPinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_NETWORK_SUBSET_PUK, "NetworkSubsetPukRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_SERVICE_PIN, "ServicePinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_SERVICE_PUK, "ServicePukRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_CORP_PIN, "CorporatePinRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_CORP_PUK, "CorporatePukRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_HIDDEN_KEY, "HiddenKeyRequired"),
ENUM_ENTRY (MM_MOBILE_ERROR_EAP_NOT_SUPPORTED, "EapMethodNotSupported"),
ENUM_ENTRY (MM_MOBILE_ERROR_INCORRECT_PARAMS, "IncorrectParams"),
ENUM_ENTRY (MM_MOBILE_ERROR_UNKNOWN, "Unknown"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_ILLEGAL_MS, "GprsIllegalMs"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_ILLEGAL_ME, "GprsIllegalMe"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_SERVICE_NOT_ALLOWED, "GprsServiceNotAllowed"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_PLMN_NOT_ALLOWED, "GprsPlmnNotAllowed"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_LOCATION_NOT_ALLOWED, "GprsLocationNotAllowed"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_ROAMING_NOT_ALLOWED, "GprsRoamingNotAllowed"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_OPTION_NOT_SUPPORTED, "GprsOptionNotSupported"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_NOT_SUBSCRIBED, "GprsNotSubscribed"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_OUT_OF_ORDER, "GprsOutOfOrder"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_PDP_AUTH_FAILURE, "GprsPdpAuthFailure"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_UNKNOWN, "GprsUnspecified"),
ENUM_ENTRY (MM_MOBILE_ERROR_GPRS_INVALID_CLASS, "GprsInvalidClass"),
{ 0, 0, 0 }
};
etype = g_enum_register_static ("MMMobileError", values);
}
return etype;
}
typedef struct {
int code;
const char *error; /* lowercase, and stripped of special chars and whitespace */
const char *message;
} ErrorTable;
static ErrorTable errors[] = {
{ MM_MOBILE_ERROR_PHONE_FAILURE, "phonefailure", "Phone failure" },
{ MM_MOBILE_ERROR_NO_CONNECTION, "noconnectiontophone", "No connection to phone" },
{ MM_MOBILE_ERROR_LINK_RESERVED, "phoneadapterlinkreserved", "Phone-adaptor link reserved" },
{ MM_MOBILE_ERROR_NOT_ALLOWED, "operationnotallowed", "Operation not allowed" },
{ MM_MOBILE_ERROR_NOT_SUPPORTED, "operationnotsupported", "Operation not supported" },
{ MM_MOBILE_ERROR_PH_SIM_PIN, "phsimpinrequired", "PH-SIM PIN required" },
{ MM_MOBILE_ERROR_PH_FSIM_PIN, "phfsimpinrequired", "PH-FSIM PIN required" },
{ MM_MOBILE_ERROR_PH_FSIM_PUK, "phfsimpukrequired", "PH-FSIM PUK required" },
{ MM_MOBILE_ERROR_SIM_NOT_INSERTED, "simnotinserted", "SIM not inserted" },
{ MM_MOBILE_ERROR_SIM_PIN, "simpinrequired", "SIM PIN required" },
{ MM_MOBILE_ERROR_SIM_PUK, "simpukrequired", "SIM PUK required" },
{ MM_MOBILE_ERROR_SIM_FAILURE, "simfailure", "SIM failure" },
{ MM_MOBILE_ERROR_SIM_BUSY, "simbusy", "SIM busy" },
{ MM_MOBILE_ERROR_SIM_WRONG, "simwrong", "SIM wrong" },
{ MM_MOBILE_ERROR_WRONG_PASSWORD, "incorrectpassword", "Incorrect password" },
{ MM_MOBILE_ERROR_SIM_PIN2, "simpin2required", "SIM PIN2 required" },
{ MM_MOBILE_ERROR_SIM_PUK2, "simpuk2required", "SIM PUK2 required" },
{ MM_MOBILE_ERROR_MEMORY_FULL, "memoryfull", "Memory full" },
{ MM_MOBILE_ERROR_INVALID_INDEX, "invalidindex", "Invalid index" },
{ MM_MOBILE_ERROR_NOT_FOUND, "notfound", "Not found" },
{ MM_MOBILE_ERROR_MEMORY_FAILURE, "memoryfailure", "Memory failure" },
{ MM_MOBILE_ERROR_TEXT_TOO_LONG, "textstringtoolong", "Text string too long" },
{ MM_MOBILE_ERROR_INVALID_CHARS, "invalidcharactersintextstring", "Invalid characters in text string" },
{ MM_MOBILE_ERROR_DIAL_STRING_TOO_LONG, "dialstringtoolong", "Dial string too long" },
{ MM_MOBILE_ERROR_DIAL_STRING_INVALID, "invalidcharactersindialstring", "Invalid characters in dial string" },
{ MM_MOBILE_ERROR_NO_NETWORK, "nonetworkservice", "No network service" },
{ MM_MOBILE_ERROR_NETWORK_TIMEOUT, "networktimeout", "Network timeout" },
{ MM_MOBILE_ERROR_NETWORK_NOT_ALLOWED, "networknotallowedemergencycallsonly", "Network not allowed - emergency calls only" },
{ MM_MOBILE_ERROR_NETWORK_PIN, "networkpersonalizationpinrequired", "Network personalization PIN required" },
{ MM_MOBILE_ERROR_NETWORK_PUK, "networkpersonalizationpukrequired", "Network personalization PUK required" },
{ MM_MOBILE_ERROR_NETWORK_SUBSET_PIN, "networksubsetpersonalizationpinrequired", "Network subset personalization PIN required" },
{ MM_MOBILE_ERROR_NETWORK_SUBSET_PUK, "networksubsetpersonalizationpukrequired", "Network subset personalization PUK required" },
{ MM_MOBILE_ERROR_SERVICE_PIN, "serviceproviderpersonalizationpinrequired", "Service provider personalization PIN required" },
{ MM_MOBILE_ERROR_SERVICE_PUK, "serviceproviderpersonalizationpukrequired", "Service provider personalization PUK required" },
{ MM_MOBILE_ERROR_CORP_PIN, "corporatepersonalizationpinrequired", "Corporate personalization PIN required" },
{ MM_MOBILE_ERROR_CORP_PUK, "corporatepersonalizationpukrequired", "Corporate personalization PUK required" },
{ MM_MOBILE_ERROR_HIDDEN_KEY, "phsimpukrequired", "Hidden key required" },
{ MM_MOBILE_ERROR_EAP_NOT_SUPPORTED, "eapmethodnotsupported", "EAP method not supported" },
{ MM_MOBILE_ERROR_INCORRECT_PARAMS, "incorrectparameters", "Incorrect parameters" },
{ MM_MOBILE_ERROR_UNKNOWN, "unknownerror", "Unknown error" },
{ MM_MOBILE_ERROR_GPRS_ILLEGAL_MS, "illegalms", "Illegal MS" },
{ MM_MOBILE_ERROR_GPRS_ILLEGAL_ME, "illegalme", "Illegal ME" },
{ MM_MOBILE_ERROR_GPRS_SERVICE_NOT_ALLOWED, "gprsservicesnotallowed", "GPRS services not allowed" },
{ MM_MOBILE_ERROR_GPRS_PLMN_NOT_ALLOWED, "plmnnotallowed", "PLMN not allowed" },
{ MM_MOBILE_ERROR_GPRS_LOCATION_NOT_ALLOWED, "locationareanotallowed", "Location area not allowed" },
{ MM_MOBILE_ERROR_GPRS_ROAMING_NOT_ALLOWED, "roamingnotallowedinthislocationarea", "Roaming not allowed in this location area" },
{ MM_MOBILE_ERROR_GPRS_OPTION_NOT_SUPPORTED, "serviceoperationnotsupported", "Service option not supported" },
{ MM_MOBILE_ERROR_GPRS_NOT_SUBSCRIBED, "requestedserviceoptionnotsubscribed", "Requested service option not subscribed" },
{ MM_MOBILE_ERROR_GPRS_OUT_OF_ORDER, "serviceoptiontemporarilyoutoforder", "Service option temporarily out of order" },
{ MM_MOBILE_ERROR_GPRS_UNKNOWN, "unspecifiedgprserror", "Unspecified GPRS error" },
{ MM_MOBILE_ERROR_GPRS_PDP_AUTH_FAILURE, "pdpauthenticationfailure", "PDP authentication failure" },
{ MM_MOBILE_ERROR_GPRS_INVALID_CLASS, "invalidmobileclass", "Invalid mobile class" },
{ -1, NULL, NULL }
};
GError *
mm_mobile_error_for_code (int error_code)
{
const char *msg = NULL;
const ErrorTable *ptr = &errors[0];
while (ptr->code >= 0) {
if (ptr->code == error_code) {
msg = ptr->message;
break;
}
ptr++;
}
if (!msg) {
g_warning ("Invalid error code: %d", error_code);
error_code = MM_MOBILE_ERROR_UNKNOWN;
msg = "Unknown error";
}
return g_error_new_literal (MM_MOBILE_ERROR, error_code, msg);
}
#define BUF_SIZE 100
GError *
mm_mobile_error_for_string (const char *str)
{
int error_code = -1;
const ErrorTable *ptr = &errors[0];
char buf[BUF_SIZE + 1];
const char *msg = NULL, *p = str;
int i = 0;
g_return_val_if_fail (str != NULL, NULL);
/* Normalize the error code by stripping whitespace and odd characters */
while (*p && i < BUF_SIZE) {
if (isalnum (*p))
buf[i++] = tolower (*p);
p++;
}
buf[i] = '\0';
while (ptr->code >= 0) {
if (!strcmp (buf, ptr->error)) {
error_code = ptr->code;
msg = ptr->message;
break;
}
ptr++;
}
if (!msg) {
g_warning ("Invalid error code: %d", error_code);
error_code = MM_MOBILE_ERROR_UNKNOWN;
msg = "Unknown error";
}
return g_error_new_literal (MM_MOBILE_ERROR, error_code, msg);
}
/********************************************************************/
GQuark
mm_msg_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0)
ret = g_quark_from_static_string ("mm_msg_error");
return ret;
}
GType
mm_msg_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const GEnumValue values[] = {
ENUM_ENTRY (MM_MSG_ERROR_ME_FAILURE, "MeFailure"),
ENUM_ENTRY (MM_MSG_ERROR_SMS_SERVICE_RESERVED, "SmsServiceReserved"),
ENUM_ENTRY (MM_MSG_ERROR_NOT_ALLOWED, "OperationNotAllowed"),
ENUM_ENTRY (MM_MSG_ERROR_NOT_SUPPORTED, "OperationNotSupported"),
ENUM_ENTRY (MM_MSG_ERROR_INVALID_PDU_PARAMETER, "InvalidPduParameter"),
ENUM_ENTRY (MM_MSG_ERROR_INVALID_TEXT_PARAMETER, "InvalidTextParameter"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_NOT_INSERTED, "SimNotInserted"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_PIN, "SimPinRequired"),
ENUM_ENTRY (MM_MSG_ERROR_PH_SIM_PIN, "PhSimPinRequired"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_FAILURE, "SimFailure"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_BUSY, "SimBusy"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_WRONG, "SimWrong"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_PUK, "SimPukRequired"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_PIN2, "SimPin2Required"),
ENUM_ENTRY (MM_MSG_ERROR_SIM_PUK2, "SimPuk2Required"),
ENUM_ENTRY (MM_MSG_ERROR_MEMORY_FAILURE, "MemoryFailure"),
ENUM_ENTRY (MM_MSG_ERROR_INVALID_INDEX, "InvalidIndex"),
ENUM_ENTRY (MM_MSG_ERROR_MEMORY_FULL, "MemoryFull"),
ENUM_ENTRY (MM_MSG_ERROR_SMSC_ADDRESS_UNKNOWN, "SmscAddressUnknown"),
ENUM_ENTRY (MM_MSG_ERROR_NO_NETWORK, "NoNetwork"),
ENUM_ENTRY (MM_MSG_ERROR_NETWORK_TIMEOUT, "NetworkTimeout"),
ENUM_ENTRY (MM_MSG_ERROR_NO_CNMA_ACK_EXPECTED, "NoCnmaAckExpected"),
ENUM_ENTRY (MM_MSG_ERROR_UNKNOWN, "Unknown"),
{ 0, 0, 0 }
};
etype = g_enum_register_static ("MMMsgError", values);
}
return etype;
}
static ErrorTable msg_errors[] = {
{ MM_MSG_ERROR_ME_FAILURE, "mefailure", "ME failure" },
{ MM_MSG_ERROR_SMS_SERVICE_RESERVED, "smsservicereserved", "SMS service reserved" },
{ MM_MSG_ERROR_NOT_ALLOWED, "operationnotallowed", "Operation not allowed" },
{ MM_MSG_ERROR_NOT_SUPPORTED, "operationnotsupported", "Operation not supported" },
{ MM_MSG_ERROR_INVALID_PDU_PARAMETER, "invalidpduparameter", "Invalid PDU mode parameter" },
{ MM_MSG_ERROR_INVALID_TEXT_PARAMETER, "invalidtextparameter", "Invalid text mode parameter" },
{ MM_MSG_ERROR_SIM_NOT_INSERTED, "simnotinserted", "SIM not inserted" },
{ MM_MSG_ERROR_SIM_PIN, "simpinrequired", "SIM PIN required" },
{ MM_MSG_ERROR_PH_SIM_PIN, "phsimpinrequired", "PH-SIM PIN required" },
{ MM_MSG_ERROR_SIM_FAILURE, "simfailure", "SIM failure" },
{ MM_MSG_ERROR_SIM_BUSY, "simbusy", "SIM busy" },
{ MM_MSG_ERROR_SIM_WRONG, "simwrong", "SIM wrong" },
{ MM_MSG_ERROR_SIM_PUK, "simpukrequired", "SIM PUK required" },
{ MM_MSG_ERROR_SIM_PIN2, "simpin2required", "SIM PIN2 required" },
{ MM_MSG_ERROR_SIM_PUK2, "simpuk2required", "SIM PUK2 required" },
{ MM_MSG_ERROR_MEMORY_FAILURE, "memoryfailure", "Memory failure" },
{ MM_MSG_ERROR_INVALID_INDEX, "invalidindex", "Invalid index" },
{ MM_MSG_ERROR_MEMORY_FULL, "memoryfull", "Memory full" },
{ MM_MSG_ERROR_SMSC_ADDRESS_UNKNOWN, "smscaddressunknown", "SMSC address unknown" },
{ MM_MSG_ERROR_NO_NETWORK, "nonetwork", "No network" },
{ MM_MSG_ERROR_NETWORK_TIMEOUT, "networktimeout", "Network timeout" },
{ MM_MSG_ERROR_NO_CNMA_ACK_EXPECTED, "nocnmaackexpected", "No CNMA acknowledgement expected" },
{ MM_MSG_ERROR_UNKNOWN, "unknown", "Unknown" },
{ -1, NULL, NULL }
};
GError *
mm_msg_error_for_code (int error_code)
{
const char *msg = NULL;
const ErrorTable *ptr = &msg_errors[0];
while (ptr->code >= 0) {
if (ptr->code == error_code) {
msg = ptr->message;
break;
}
ptr++;
}
if (!msg) {
g_warning ("Invalid error code: %d", error_code);
error_code = MM_MSG_ERROR_UNKNOWN;
msg = "Unknown error";
}
return g_error_new_literal (MM_MSG_ERROR, error_code, msg);
}
#define BUF_SIZE 100
GError *
mm_msg_error_for_string (const char *str)
{
int error_code = -1;
const ErrorTable *ptr = &msg_errors[0];
char buf[BUF_SIZE + 1];
const char *msg = NULL, *p = str;
int i = 0;
g_return_val_if_fail (str != NULL, NULL);
/* Normalize the error code by stripping whitespace and odd characters */
while (*p && i < BUF_SIZE) {
if (isalnum (*p))
buf[i++] = tolower (*p);
p++;
}
buf[i] = '\0';
while (ptr->code >= 0) {
if (!strcmp (buf, ptr->error)) {
error_code = ptr->code;
msg = ptr->message;
break;
}
ptr++;
}
if (!msg) {
g_warning ("Invalid error code: %d", error_code);
error_code = MM_MSG_ERROR_UNKNOWN;
msg = "Unknown error";
}
return g_error_new_literal (MM_MSG_ERROR, error_code, msg);
}

View File

@@ -1,163 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program 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.
*
* This program 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:
*
* Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
*/
#ifndef MM_MODEM_ERROR_H
#define MM_MODEM_ERROR_H
#include <glib-object.h>
#include <ModemManager-errors.h>
#include <mm-errors-types.h>
enum {
MM_MODEM_ERROR_GENERAL = 0,
MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED = 1,
MM_MODEM_ERROR_CONNECTED = 2,
MM_MODEM_ERROR_DISCONNECTED = 3,
MM_MODEM_ERROR_OPERATION_IN_PROGRESS = 4,
MM_MODEM_ERROR_REMOVED = 5,
MM_MODEM_ERROR_AUTHORIZATION_REQUIRED = 6,
MM_MODEM_ERROR_UNSUPPORTED_CHARSET = 7
};
#define MM_MODEM_ERROR (mm_modem_error_quark ())
#define MM_TYPE_MODEM_ERROR (mm_modem_error_get_type ())
GQuark mm_modem_error_quark (void);
GType mm_modem_error_get_type (void);
enum {
MM_MODEM_CONNECT_ERROR_NO_CARRIER = 3,
MM_MODEM_CONNECT_ERROR_NO_DIALTONE = 6,
MM_MODEM_CONNECT_ERROR_BUSY = 7,
MM_MODEM_CONNECT_ERROR_NO_ANSWER = 8,
};
#define MM_MODEM_CONNECT_ERROR (mm_modem_connect_error_quark ())
#define MM_TYPE_MODEM_CONNECT_ERROR (mm_modem_connect_error_get_type ())
GQuark mm_modem_connect_error_quark (void);
GType mm_modem_connect_error_get_type (void);
GError *mm_modem_connect_error_for_code (int error_code);
/* 3GPP TS 07.07 version 7.8.0 Release 1998 (page 90) ETSI TS 100 916 V7.8.0 (2003-03) */
enum {
MM_MOBILE_ERROR_PHONE_FAILURE = 0,
MM_MOBILE_ERROR_NO_CONNECTION = 1,
MM_MOBILE_ERROR_LINK_RESERVED = 2,
MM_MOBILE_ERROR_NOT_ALLOWED = 3,
MM_MOBILE_ERROR_NOT_SUPPORTED = 4,
MM_MOBILE_ERROR_PH_SIM_PIN = 5,
MM_MOBILE_ERROR_PH_FSIM_PIN = 6,
MM_MOBILE_ERROR_PH_FSIM_PUK = 7,
MM_MOBILE_ERROR_SIM_NOT_INSERTED = 10,
MM_MOBILE_ERROR_SIM_PIN = 11,
MM_MOBILE_ERROR_SIM_PUK = 12,
MM_MOBILE_ERROR_SIM_FAILURE = 13,
MM_MOBILE_ERROR_SIM_BUSY = 14,
MM_MOBILE_ERROR_SIM_WRONG = 15,
MM_MOBILE_ERROR_WRONG_PASSWORD = 16,
MM_MOBILE_ERROR_SIM_PIN2 = 17,
MM_MOBILE_ERROR_SIM_PUK2 = 18,
MM_MOBILE_ERROR_MEMORY_FULL = 20,
MM_MOBILE_ERROR_INVALID_INDEX = 21,
MM_MOBILE_ERROR_NOT_FOUND = 22,
MM_MOBILE_ERROR_MEMORY_FAILURE = 23,
MM_MOBILE_ERROR_TEXT_TOO_LONG = 24,
MM_MOBILE_ERROR_INVALID_CHARS = 25,
MM_MOBILE_ERROR_DIAL_STRING_TOO_LONG = 26,
MM_MOBILE_ERROR_DIAL_STRING_INVALID = 27,
MM_MOBILE_ERROR_NO_NETWORK = 30,
MM_MOBILE_ERROR_NETWORK_TIMEOUT = 31,
MM_MOBILE_ERROR_NETWORK_NOT_ALLOWED = 32,
MM_MOBILE_ERROR_NETWORK_PIN = 40,
MM_MOBILE_ERROR_NETWORK_PUK = 41,
MM_MOBILE_ERROR_NETWORK_SUBSET_PIN = 42,
MM_MOBILE_ERROR_NETWORK_SUBSET_PUK = 43,
MM_MOBILE_ERROR_SERVICE_PIN = 44,
MM_MOBILE_ERROR_SERVICE_PUK = 45,
MM_MOBILE_ERROR_CORP_PIN = 46,
MM_MOBILE_ERROR_CORP_PUK = 47,
MM_MOBILE_ERROR_HIDDEN_KEY = 48,
MM_MOBILE_ERROR_EAP_NOT_SUPPORTED = 49,
MM_MOBILE_ERROR_INCORRECT_PARAMS = 50,
MM_MOBILE_ERROR_UNKNOWN = 100,
MM_MOBILE_ERROR_GPRS_ILLEGAL_MS = 103,
MM_MOBILE_ERROR_GPRS_ILLEGAL_ME = 106,
MM_MOBILE_ERROR_GPRS_SERVICE_NOT_ALLOWED = 107,
MM_MOBILE_ERROR_GPRS_PLMN_NOT_ALLOWED = 111,
MM_MOBILE_ERROR_GPRS_LOCATION_NOT_ALLOWED = 112,
MM_MOBILE_ERROR_GPRS_ROAMING_NOT_ALLOWED = 113,
MM_MOBILE_ERROR_GPRS_OPTION_NOT_SUPPORTED = 132,
MM_MOBILE_ERROR_GPRS_NOT_SUBSCRIBED = 133,
MM_MOBILE_ERROR_GPRS_OUT_OF_ORDER = 134,
MM_MOBILE_ERROR_GPRS_UNKNOWN = 148,
MM_MOBILE_ERROR_GPRS_PDP_AUTH_FAILURE = 149,
MM_MOBILE_ERROR_GPRS_INVALID_CLASS = 150
};
#define MM_MOBILE_ERROR (mm_mobile_error_quark ())
#define MM_TYPE_MOBILE_ERROR (mm_mobile_error_get_type ())
GQuark mm_mobile_error_quark (void);
GType mm_mobile_error_get_type (void);
GError *mm_mobile_error_for_code (int error_code);
GError *mm_mobile_error_for_string (const char *str);
/* 3GPP TS 27.005 version 10 section 3.2.5 */
enum {
/* 0 -> 127 per 3GPP TS 24.011 [6] clause E.2 */
/* 128 -> 255 per 3GPP TS 23.040 [3] clause 9.2.3.22 */
MM_MSG_ERROR_ME_FAILURE = 300,
MM_MSG_ERROR_SMS_SERVICE_RESERVED = 301,
MM_MSG_ERROR_NOT_ALLOWED = 302,
MM_MSG_ERROR_NOT_SUPPORTED = 303,
MM_MSG_ERROR_INVALID_PDU_PARAMETER = 304,
MM_MSG_ERROR_INVALID_TEXT_PARAMETER = 305,
MM_MSG_ERROR_SIM_NOT_INSERTED = 310,
MM_MSG_ERROR_SIM_PIN = 311,
MM_MSG_ERROR_PH_SIM_PIN = 312,
MM_MSG_ERROR_SIM_FAILURE = 313,
MM_MSG_ERROR_SIM_BUSY = 314,
MM_MSG_ERROR_SIM_WRONG = 315,
MM_MSG_ERROR_SIM_PUK = 316,
MM_MSG_ERROR_SIM_PIN2 = 317,
MM_MSG_ERROR_SIM_PUK2 = 318,
MM_MSG_ERROR_MEMORY_FAILURE = 320,
MM_MSG_ERROR_INVALID_INDEX = 321,
MM_MSG_ERROR_MEMORY_FULL = 322,
MM_MSG_ERROR_SMSC_ADDRESS_UNKNOWN = 330,
MM_MSG_ERROR_NO_NETWORK = 331,
MM_MSG_ERROR_NETWORK_TIMEOUT = 332,
MM_MSG_ERROR_NO_CNMA_ACK_EXPECTED = 340,
MM_MSG_ERROR_UNKNOWN = 500,
};
#define MM_MSG_ERROR (mm_msg_error_quark ())
#define MM_TYPE_MSG_ERROR (mm_msg_error_get_type ())
GQuark mm_msg_error_quark (void);
GType mm_msg_error_get_type (void);
GError *mm_msg_error_for_code (int error_code);
GError *mm_msg_error_for_string (const char *str);
#endif /* MM_MODEM_ERROR_H */

View File

@@ -24,6 +24,9 @@
#include <string.h>
#include <unistd.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-log.h"
enum {
@@ -176,7 +179,8 @@ mm_log_set_level (const char *level, GError **error)
}
}
if (!found)
g_set_error (error, 0, 0, "Unknown log level '%s'", level);
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
"Unknown log level '%s'", level);
return found;
}
@@ -206,13 +210,14 @@ mm_log_setup (const char *level,
O_CREAT | O_APPEND | O_WRONLY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (logfd < 0) {
g_set_error (error, 0, 0, "Failed to open log file: (%d) %s",
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't open log file: (%d) %s",
errno, strerror (errno));
return FALSE;
}
}
g_log_set_handler (G_LOG_DOMAIN,
g_log_set_handler (G_LOG_DOMAIN,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
log_handler,
NULL);

View File

@@ -25,13 +25,12 @@
#include <gudev/gudev.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include <mm-gdbus-manager.h>
#include "mm-manager.h"
#include "mm-plugin-manager.h"
#include "mm-auth-provider.h"
#include "mm-errors.h"
#include "mm-plugin.h"
#include "mm-log.h"
#include "mm-port-probe-cache.h"
@@ -748,8 +747,8 @@ scan_devices_request_auth_cb (MMAuthRequest *req,
{
if (mm_auth_request_get_result (req) != MM_AUTH_RESULT_AUTHORIZED) {
g_dbus_method_invocation_return_error (invocation,
MM_MODEM_ERROR,
MM_MODEM_ERROR_AUTHORIZATION_REQUIRED,
MM_CORE_ERROR,
MM_CORE_ERROR_UNAUTHORIZED,
"This request requires the '%s' authorization",
mm_auth_request_get_authorization (req));
return;

View File

@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <errno.h>
#include "mm-errors.h"
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-modem-helpers.h"
#include "mm-log.h"
@@ -91,7 +93,7 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
if (!strstr (reply, "+COPS: ")) {
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not parse scan results.");
return NULL;
}
@@ -117,7 +119,7 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
mm_err ("Invalid regular expression: %s", err->message);
g_error_free (err);
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not parse scan results.");
return NULL;
}
@@ -146,7 +148,7 @@ mm_gsm_parse_scan_response (const char *reply, GError **error)
mm_err ("Invalid regular expression: %s", err->message);
g_error_free (err);
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not parse scan results.");
return NULL;
}
@@ -452,7 +454,7 @@ mm_gsm_parse_creg_response (GMatchInfo *info,
g_free (str);
if (!success) {
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not parse the registration status response");
return FALSE;
}
@@ -1170,7 +1172,7 @@ mm_parse_cind_test_response (const char *reply, GError **error)
r = g_regex_new ("\\(([^,]*),\\((\\d+)[-,](\\d+)\\)", G_REGEX_UNGREEDY, 0, NULL);
if (!r) {
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not parse scan results.");
return NULL;
}
@@ -1220,7 +1222,7 @@ mm_parse_cind_query_response(const char *reply, GError **error)
g_return_val_if_fail (reply != NULL, NULL);
if (!g_str_has_prefix (p, CIND_TAG)) {
g_set_error_literal (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error_literal (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Could not parse the +CIND response");
return NULL;
}
@@ -1231,13 +1233,13 @@ mm_parse_cind_query_response(const char *reply, GError **error)
r = g_regex_new ("(\\d+)[^0-9]+", G_REGEX_UNGREEDY, 0, NULL);
if (!r) {
g_set_error_literal (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error_literal (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Internal failure attempting to parse +CIND response");
return NULL;
}
if (!g_regex_match_full (r, p, strlen (p), 0, 0, &match_info, NULL)) {
g_set_error_literal (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error_literal (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Failure parsing the +CIND response");
goto done;
}

View File

@@ -35,7 +35,6 @@
#include "mm-at-serial-port.h"
#include "mm-qcdm-serial-port.h"
#include "mm-serial-parsers.h"
#include "mm-errors.h"
#include "mm-marshal.h"
#include "mm-utils.h"
#include "libqcdm/src/commands.h"

View File

@@ -21,9 +21,11 @@
#include <gmodule.h>
#include <gio/gio.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-plugin-manager.h"
#include "mm-plugin.h"
#include "mm-errors.h"
#include "mm-log.h"
/* Default time to defer probing checks */

View File

@@ -20,7 +20,9 @@
#include <glib.h>
#include "mm-errors.h"
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-port-probe.h"
#include "mm-port-probe-at-command.h"
@@ -40,7 +42,7 @@ parse_at (const gchar *response,
return FALSE; /* Retry */
/* If error is not recognizable, request to abort */
if (error->domain != MM_MOBILE_ERROR) {
if (error->domain != MM_MOBILE_EQUIPMENT_ERROR) {
*result_error = g_error_copy (error);
g_prefix_error (result_error,
"Couldn't parse AT reply. ");

View File

@@ -20,11 +20,9 @@
#include <string.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-port-probe.h"
#include "mm-errors.h"
#include "mm-log.h"
#include "mm-at-serial-port.h"
#include "mm-serial-port.h"
@@ -633,8 +631,8 @@ serial_open_at (MMPortProbe *self)
task,
FALSE,
FALSE,
g_error_new (MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
g_error_new (MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"(%s) failed to open port after 4 tries",
self->priv->name));
} else if (g_error_matches (error,

View File

@@ -19,8 +19,10 @@
#include <unistd.h>
#include <string.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-qcdm-serial-port.h"
#include "mm-errors.h"
#include "libqcdm/src/com.h"
#include "libqcdm/src/utils.h"
#include "libqcdm/src/errors.h"
@@ -92,7 +94,7 @@ handle_response (MMSerialPort *port,
/* Get the offset into the buffer of where the QCDM frame starts */
if (!find_qcdm_start (response, &start)) {
g_set_error_literal (&dm_error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Failed to parse QCDM packet.");
/* Discard the unparsable data */
used = response->len;
@@ -110,7 +112,7 @@ handle_response (MMSerialPort *port,
&more);
if (!success) {
g_set_error_literal (&dm_error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Failed to unescape QCDM packet.");
g_byte_array_free (unescaped, TRUE);
unescaped = NULL;

View File

@@ -17,8 +17,8 @@
#include <string.h>
#include <stdlib.h>
#include "mm-error-helpers.h"
#include "mm-serial-parsers.h"
#include "mm-errors.h"
#include "mm-log.h"
/* Clean up the response by removing control characters like <CR><LF> etc */
@@ -125,7 +125,7 @@ mm_serial_parser_v0_parse (gpointer data,
code = atoi (str);
g_free (str);
} else
code = MM_MOBILE_ERROR_UNKNOWN;
code = MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN;
switch (code) {
case 0: /* OK */
@@ -133,22 +133,22 @@ mm_serial_parser_v0_parse (gpointer data,
case 1: /* CONNECT */
break;
case 3: /* NO CARRIER */
local_error = mm_modem_connect_error_for_code (MM_MODEM_CONNECT_ERROR_NO_CARRIER);
local_error = mm_connection_error_for_code (MM_CONNECTION_ERROR_NO_CARRIER);
break;
case 4: /* ERROR */
local_error = mm_mobile_error_for_code (MM_MOBILE_ERROR_UNKNOWN);
local_error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN);
break;
case 6: /* NO DIALTONE */
local_error = mm_modem_connect_error_for_code (MM_MODEM_CONNECT_ERROR_NO_DIALTONE);
local_error = mm_connection_error_for_code (MM_CONNECTION_ERROR_NO_DIALTONE);
break;
case 7: /* BUSY */
local_error = mm_modem_connect_error_for_code (MM_MODEM_CONNECT_ERROR_BUSY);
local_error = mm_connection_error_for_code (MM_CONNECTION_ERROR_BUSY);
break;
case 8: /* NO ANSWER */
local_error = mm_modem_connect_error_for_code (MM_MODEM_CONNECT_ERROR_NO_ANSWER);
local_error = mm_connection_error_for_code (MM_CONNECTION_ERROR_NO_ANSWER);
break;
default:
local_error = mm_mobile_error_for_code (MM_MOBILE_ERROR_UNKNOWN);
local_error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN);
break;
}
@@ -165,9 +165,9 @@ mm_serial_parser_v0_parse (gpointer data,
code = atoi (str);
g_free (str);
} else
code = MM_MOBILE_ERROR_UNKNOWN;
code = MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN;
local_error = mm_mobile_error_for_code (code);
local_error = mm_mobile_equipment_error_for_code (code);
}
g_match_info_free (match_info);
@@ -179,9 +179,9 @@ mm_serial_parser_v0_parse (gpointer data,
code = atoi (str);
g_free (str);
} else
code = MM_MSG_ERROR_UNKNOWN;
code = MM_MESSAGE_ERROR_UNKNOWN;
local_error = mm_msg_error_for_code (code);
local_error = mm_message_error_for_code (code);
}
g_match_info_free (match_info);
}
@@ -280,7 +280,6 @@ mm_serial_parser_v1_parse (gpointer data,
GError *local_error = NULL;
gboolean found = FALSE;
char *str = NULL;
int code;
g_return_val_if_fail (parser != NULL, FALSE);
g_return_val_if_fail (response != NULL, FALSE);
@@ -328,7 +327,7 @@ mm_serial_parser_v1_parse (gpointer data,
if (found) {
str = g_match_info_fetch (match_info, 1);
g_assert (str);
local_error = mm_mobile_error_for_code (atoi (str));
local_error = mm_mobile_equipment_error_for_code (atoi (str));
goto done;
}
g_match_info_free (match_info);
@@ -341,7 +340,7 @@ mm_serial_parser_v1_parse (gpointer data,
if (found) {
str = g_match_info_fetch (match_info, 1);
g_assert (str);
local_error = mm_mobile_error_for_code (atoi (str));
local_error = mm_mobile_equipment_error_for_code (atoi (str));
goto done;
}
g_match_info_free (match_info);
@@ -353,7 +352,7 @@ mm_serial_parser_v1_parse (gpointer data,
if (found) {
str = g_match_info_fetch (match_info, 1);
g_assert (str);
local_error = mm_msg_error_for_code (atoi (str));
local_error = mm_message_error_for_code (atoi (str));
goto done;
}
g_match_info_free (match_info);
@@ -365,7 +364,7 @@ mm_serial_parser_v1_parse (gpointer data,
if (found) {
str = g_match_info_fetch (match_info, 1);
g_assert (str);
local_error = mm_mobile_error_for_string (str);
local_error = mm_mobile_equipment_error_for_string (str);
goto done;
}
g_match_info_free (match_info);
@@ -377,7 +376,7 @@ mm_serial_parser_v1_parse (gpointer data,
if (found) {
str = g_match_info_fetch (match_info, 1);
g_assert (str);
local_error = mm_msg_error_for_string (str);
local_error = mm_message_error_for_string (str);
goto done;
}
g_match_info_free (match_info);
@@ -389,7 +388,7 @@ mm_serial_parser_v1_parse (gpointer data,
if (found) {
str = g_match_info_fetch (match_info, 1);
g_assert (str);
local_error = mm_mobile_error_for_code (MM_MOBILE_ERROR_UNKNOWN);
local_error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN);
goto done;
}
g_match_info_free (match_info);
@@ -399,7 +398,7 @@ mm_serial_parser_v1_parse (gpointer data,
response->str, response->len,
0, 0, &match_info, NULL);
if (found) {
local_error = mm_mobile_error_for_code (MM_MOBILE_ERROR_UNKNOWN);
local_error = mm_mobile_equipment_error_for_code (MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN);
goto done;
}
g_match_info_free (match_info);
@@ -409,23 +408,25 @@ mm_serial_parser_v1_parse (gpointer data,
response->str, response->len,
0, 0, &match_info, NULL);
if (found) {
MMConnectionError code;
str = g_match_info_fetch (match_info, 1);
g_assert (str);
if (!strcmp (str, "NO CARRIER"))
code = MM_MODEM_CONNECT_ERROR_NO_CARRIER;
code = MM_CONNECTION_ERROR_NO_CARRIER;
else if (!strcmp (str, "BUSY"))
code = MM_MODEM_CONNECT_ERROR_BUSY;
code = MM_CONNECTION_ERROR_BUSY;
else if (!strcmp (str, "NO ANSWER"))
code = MM_MODEM_CONNECT_ERROR_NO_ANSWER;
code = MM_CONNECTION_ERROR_NO_ANSWER;
else if (!strcmp (str, "NO DIALTONE"))
code = MM_MODEM_CONNECT_ERROR_NO_DIALTONE;
code = MM_CONNECTION_ERROR_NO_DIALTONE;
else {
/* uhm... make something up (yes, ok, lie!). */
code = MM_MODEM_CONNECT_ERROR_NO_CARRIER;
code = MM_CONNECTION_ERROR_NO_CARRIER;
}
local_error = mm_modem_connect_error_for_code (code);
local_error = mm_connection_error_for_code (code);
}
done:

View File

@@ -28,8 +28,10 @@
#include <string.h>
#include <linux/serial.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-serial-port.h"
#include "mm-errors.h"
#include "mm-log.h"
static gboolean mm_serial_port_queue_process (gpointer data);
@@ -365,8 +367,8 @@ real_config_fd (MMSerialPort *self, int fd, GError **error)
errno = 0;
if (cfsetispeed (&stbuf, speed) != 0) {
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: failed to set serial port input speed; errno %d",
__func__, errno);
return FALSE;
@@ -375,8 +377,8 @@ real_config_fd (MMSerialPort *self, int fd, GError **error)
errno = 0;
if (cfsetospeed (&stbuf, speed) != 0) {
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: failed to set serial port output speed; errno %d",
__func__, errno);
return FALSE;
@@ -384,8 +386,8 @@ real_config_fd (MMSerialPort *self, int fd, GError **error)
if (tcsetattr (fd, TCSANOW, &stbuf) < 0) {
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: failed to set serial port attributes; errno %d",
__func__, errno);
return FALSE;
@@ -1091,8 +1093,8 @@ get_speed (MMSerialPort *self, speed_t *speed, GError **error)
memset (&options, 0, sizeof (struct termios));
if (tcgetattr (MM_SERIAL_PORT_GET_PRIVATE (self)->fd, &options) != 0) {
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: tcgetattr() error %d",
__func__, errno);
return FALSE;
@@ -1115,8 +1117,8 @@ set_speed (MMSerialPort *self, speed_t speed, GError **error)
memset (&options, 0, sizeof (struct termios));
if (tcgetattr (fd, &options) != 0) {
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: tcgetattr() error %d",
__func__, errno);
return FALSE;
@@ -1142,8 +1144,8 @@ set_speed (MMSerialPort *self, speed_t speed, GError **error)
else {
/* If not EAGAIN, hard error */
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: tcsetattr() error %d",
__func__, errno);
return FALSE;
@@ -1152,8 +1154,8 @@ set_speed (MMSerialPort *self, speed_t speed, GError **error)
if (!success) {
g_set_error (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"%s: tcsetattr() retry timeout",
__func__);
return FALSE;
@@ -1220,8 +1222,8 @@ mm_serial_port_flash (MMSerialPort *self,
}
if (priv->flash_id > 0) {
error = g_error_new_literal (MM_MODEM_ERROR,
MM_MODEM_ERROR_OPERATION_IN_PROGRESS,
error = g_error_new_literal (MM_CORE_ERROR,
MM_CORE_ERROR_IN_PROGRESS,
"Modem is already being flashed.");
goto error;
}

View File

@@ -34,7 +34,6 @@
#include "mm-sim.h"
#include "mm-base-modem.h"
#include "mm-utils.h"
#include "mm-errors.h"
#include "mm-log.h"
#include "mm-modem-helpers.h"

View File

@@ -18,8 +18,10 @@
#include <glib.h>
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-charsets.h"
#include "mm-errors.h"
#include "mm-utils.h"
#include "mm-sms-utils.h"
#include "mm-log.h"
@@ -397,7 +399,7 @@ sms_parse_pdu (const char *hexpdu, GError **error)
/* Convert PDU from hex to binary */
pdu = (guint8 *) utils_hexstr2bin (hexpdu, &pdu_len);
if (!pdu) {
g_set_error_literal (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error_literal (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't parse PDU of SMS GET response from hex");
return NULL;
}
@@ -406,7 +408,7 @@ sms_parse_pdu (const char *hexpdu, GError **error)
smsc_addr_num_octets = pdu[0];
variable_length_items = smsc_addr_num_octets;
if (pdu_len < variable_length_items + SMS_MIN_PDU_LEN) {
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"PDU too short (1): %zd vs %d",
pdu_len,
variable_length_items + SMS_MIN_PDU_LEN);
@@ -424,7 +426,7 @@ sms_parse_pdu (const char *hexpdu, GError **error)
sender_addr_num_octets = (sender_addr_num_digits + 1) >> 1;
variable_length_items += sender_addr_num_octets;
if (pdu_len < variable_length_items + SMS_MIN_PDU_LEN) {
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"PDU too short (2): %zd vs %d",
pdu_len,
variable_length_items + SMS_MIN_PDU_LEN);
@@ -444,7 +446,7 @@ sms_parse_pdu (const char *hexpdu, GError **error)
else
variable_length_items += user_data_len;
if (pdu_len < variable_length_items + SMS_MIN_PDU_LEN) {
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"PDU too short (3): %zd vs %d",
pdu_len,
variable_length_items + SMS_MIN_PDU_LEN);
@@ -454,7 +456,7 @@ sms_parse_pdu (const char *hexpdu, GError **error)
/* Only handle SMS-DELIVER */
if ((pdu[msg_start_offset] & SMS_TP_MTI_MASK) != SMS_TP_MTI_SMS_DELIVER) {
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Unhandled message type: 0x%02x",
pdu[msg_start_offset]);
g_free (pdu);
@@ -662,8 +664,8 @@ sms_create_submit_pdu (const char *number,
textlen = mm_charset_get_encoded_len (text, MM_MODEM_CHARSET_GSM, &gsm_unsupported);
if (textlen > 160) {
g_set_error_literal (error,
MM_MODEM_ERROR,
MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Cannot encode message to fit into an SMS.");
return NULL;
}
@@ -679,7 +681,7 @@ sms_create_submit_pdu (const char *number,
textlen = ucs2len;
}
}
/* Build up the PDU */
pdu = g_malloc0 (PDU_SIZE);
g_return_val_if_fail (pdu != NULL, NULL);
@@ -688,8 +690,8 @@ sms_create_submit_pdu (const char *number,
len = sms_encode_address (smsc, pdu, PDU_SIZE, TRUE);
if (len == 0) {
g_set_error (error,
MM_MSG_ERROR,
MM_MSG_ERROR_INVALID_PDU_PARAMETER,
MM_MESSAGE_ERROR,
MM_MESSAGE_ERROR_INVALID_PDU_PARAMETER,
"Invalid SMSC address '%s'", smsc);
goto error;
}
@@ -713,8 +715,8 @@ sms_create_submit_pdu (const char *number,
len = sms_encode_address (number, &pdu[offset], PDU_SIZE - offset, FALSE);
if (len == 0) {
g_set_error (error,
MM_MSG_ERROR,
MM_MSG_ERROR_INVALID_PDU_PARAMETER,
MM_MESSAGE_ERROR,
MM_MESSAGE_ERROR_INVALID_PDU_PARAMETER,
"Invalid send-to number '%s'", number);
goto error;
}
@@ -744,8 +746,8 @@ sms_create_submit_pdu (const char *number,
if (!unpacked || unlen == 0) {
g_free (unpacked);
g_set_error_literal (error,
MM_MSG_ERROR,
MM_MSG_ERROR_INVALID_PDU_PARAMETER,
MM_MESSAGE_ERROR,
MM_MESSAGE_ERROR_INVALID_PDU_PARAMETER,
"Failed to convert message text to GSM.");
goto error;
}
@@ -755,8 +757,8 @@ sms_create_submit_pdu (const char *number,
if (!packed || packlen == 0) {
g_free (packed);
g_set_error_literal (error,
MM_MSG_ERROR,
MM_MSG_ERROR_INVALID_PDU_PARAMETER,
MM_MESSAGE_ERROR,
MM_MESSAGE_ERROR_INVALID_PDU_PARAMETER,
"Failed to pack message text to GSM.");
goto error;
}
@@ -771,8 +773,8 @@ sms_create_submit_pdu (const char *number,
if (!mm_modem_charset_byte_array_append (array, text, FALSE, best_cs)) {
g_byte_array_free (array, TRUE);
g_set_error_literal (error,
MM_MSG_ERROR,
MM_MSG_ERROR_INVALID_PDU_PARAMETER,
MM_MESSAGE_ERROR,
MM_MESSAGE_ERROR_INVALID_PDU_PARAMETER,
"Failed to convert message text to UCS2.");
goto error;
}
@@ -791,4 +793,3 @@ error:
g_free (pdu);
return NULL;
}

View File

@@ -26,7 +26,9 @@
#include <sys/wait.h>
#include <signal.h>
#include "mm-errors.h"
#include <ModemManager.h>
#include <mm-errors-types.h>
#include "mm-qcdm-serial-port.h"
#include "libqcdm/src/commands.h"
#include "libqcdm/src/utils.h"
@@ -275,7 +277,7 @@ qcdm_verinfo_expect_fail_cb (MMQcdmSerialPort *port,
{
GMainLoop *loop = user_data;
g_assert_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL);
g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);
g_main_loop_quit (loop);
}
@@ -461,7 +463,7 @@ int main (int argc, char **argv)
GTestSuite *suite;
gint result;
TestData *data = NULL;
g_test_init (&argc, &argv, NULL);
suite = g_test_get_root ();