aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/mm-charsets.c71
-rw-r--r--src/mm-charsets.h38
-rw-r--r--src/mm-modem.c48
-rw-r--r--src/mm-modem.h17
5 files changed, 112 insertions, 64 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index fff65a79..fab81da0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,8 @@ modem_manager_SOURCES = \
main.c \
mm-callback-info.c \
mm-callback-info.h \
+ mm-charsets.c \
+ mm-charsets.h \
$(auth_sources) \
mm-manager.c \
mm-manager.h \
diff --git a/src/mm-charsets.c b/src/mm-charsets.c
new file mode 100644
index 00000000..36cdd0aa
--- /dev/null
+++ b/src/mm-charsets.c
@@ -0,0 +1,71 @@
+/* -*- 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) 2010 Red Hat, Inc.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "mm-charsets.h"
+
+typedef struct {
+ const char *name;
+ MMModemCharset charset;
+} CharsetEntry;
+
+static CharsetEntry charset_map[] = {
+ { "UTF-8", MM_MODEM_CHARSET_UTF8 },
+ { "UCS2", MM_MODEM_CHARSET_UCS2 },
+ { "IRA", MM_MODEM_CHARSET_IRA },
+ { "GSM", MM_MODEM_CHARSET_GSM },
+ { "8859-1", MM_MODEM_CHARSET_8859_1 },
+ { "PCCP437", MM_MODEM_CHARSET_PCCP437 },
+ { "PCDN", MM_MODEM_CHARSET_PCDN },
+ { "HEX", MM_MODEM_CHARSET_HEX },
+ { NULL, MM_MODEM_CHARSET_UNKNOWN }
+};
+
+const char *
+mm_modem_charset_to_string (MMModemCharset charset)
+{
+ CharsetEntry *iter = &charset_map[0];
+
+ g_return_val_if_fail (charset != MM_MODEM_CHARSET_UNKNOWN, NULL);
+
+ while (iter->name) {
+ if (iter->charset == charset)
+ return iter->name;
+ iter++;
+ }
+ g_warn_if_reached ();
+ return NULL;
+}
+
+MMModemCharset
+mm_modem_charset_from_string (const char *string)
+{
+ CharsetEntry *iter = &charset_map[0];
+
+ g_return_val_if_fail (string != NULL, MM_MODEM_CHARSET_UNKNOWN);
+
+ while (iter->name) {
+ if (strcasestr (string, iter->name))
+ return iter->charset;
+ iter++;
+ }
+ return MM_MODEM_CHARSET_UNKNOWN;
+}
+
diff --git a/src/mm-charsets.h b/src/mm-charsets.h
new file mode 100644
index 00000000..3e5b90e1
--- /dev/null
+++ b/src/mm-charsets.h
@@ -0,0 +1,38 @@
+/* -*- 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) 2010 Red Hat, Inc.
+ */
+
+#ifndef MM_CHARSETS_H
+#define MM_CHARSETS_H
+
+#include <glib.h>
+
+typedef enum {
+ MM_MODEM_CHARSET_UNKNOWN = 0x00000000,
+ MM_MODEM_CHARSET_GSM = 0x00000001,
+ MM_MODEM_CHARSET_IRA = 0x00000002,
+ MM_MODEM_CHARSET_8859_1 = 0x00000004,
+ MM_MODEM_CHARSET_UTF8 = 0x00000008,
+ MM_MODEM_CHARSET_UCS2 = 0x00000010,
+ MM_MODEM_CHARSET_PCCP437 = 0x00000020,
+ MM_MODEM_CHARSET_PCDN = 0x00000040,
+ MM_MODEM_CHARSET_HEX = 0x00000080
+} MMModemCharset;
+
+const char *mm_modem_charset_to_string (MMModemCharset charset);
+
+MMModemCharset mm_modem_charset_from_string (const char *string);
+
+#endif /* MM_CHARSETS_H */
+
diff --git a/src/mm-modem.c b/src/mm-modem.c
index 6446e16d..5bc970c6 100644
--- a/src/mm-modem.c
+++ b/src/mm-modem.c
@@ -514,54 +514,6 @@ mm_modem_set_charset (MMModem *self,
}
}
-typedef struct {
- const char *name;
- MMModemCharset charset;
-} CharsetEntry;
-
-static CharsetEntry charset_map[] = {
- { "UTF-8", MM_MODEM_CHARSET_UTF8 },
- { "UCS2", MM_MODEM_CHARSET_UCS2 },
- { "IRA", MM_MODEM_CHARSET_IRA },
- { "GSM", MM_MODEM_CHARSET_GSM },
- { "8859-1", MM_MODEM_CHARSET_8859_1 },
- { "PCCP437", MM_MODEM_CHARSET_PCCP437 },
- { "PCDN", MM_MODEM_CHARSET_PCDN },
- { "HEX", MM_MODEM_CHARSET_HEX },
- { NULL, MM_MODEM_CHARSET_UNKNOWN }
-};
-
-const char *
-mm_modem_charset_to_string (MMModemCharset charset)
-{
- CharsetEntry *iter = &charset_map[0];
-
- g_return_val_if_fail (charset != MM_MODEM_CHARSET_UNKNOWN, NULL);
-
- while (iter->name) {
- if (iter->charset == charset)
- return iter->name;
- iter++;
- }
- g_warn_if_reached ();
- return NULL;
-}
-
-MMModemCharset
-mm_modem_charset_from_string (const char *string)
-{
- CharsetEntry *iter = &charset_map[0];
-
- g_return_val_if_fail (string != NULL, MM_MODEM_CHARSET_UNKNOWN);
-
- while (iter->name) {
- if (strcasestr (string, iter->name))
- return iter->charset;
- iter++;
- }
- return MM_MODEM_CHARSET_UNKNOWN;
-}
-
/*****************************************************************************/
gboolean
diff --git a/src/mm-modem.h b/src/mm-modem.h
index 5fc4bdcb..6eeb4dea 100644
--- a/src/mm-modem.h
+++ b/src/mm-modem.h
@@ -22,6 +22,7 @@
#include "mm-port.h"
#include "mm-auth-provider.h"
+#include "mm-charsets.h"
typedef enum {
MM_MODEM_STATE_UNKNOWN = 0,
@@ -42,18 +43,6 @@ typedef enum {
MM_MODEM_STATE_REASON_NONE = 0
} MMModemStateReason;
-typedef enum {
- MM_MODEM_CHARSET_UNKNOWN = 0x00000000,
- MM_MODEM_CHARSET_GSM = 0x00000001,
- MM_MODEM_CHARSET_IRA = 0x00000002,
- MM_MODEM_CHARSET_8859_1 = 0x00000004,
- MM_MODEM_CHARSET_UTF8 = 0x00000008,
- MM_MODEM_CHARSET_UCS2 = 0x00000010,
- MM_MODEM_CHARSET_PCCP437 = 0x00000020,
- MM_MODEM_CHARSET_PCDN = 0x00000040,
- MM_MODEM_CHARSET_HEX = 0x00000080
-} MMModemCharset;
-
#define DBUS_PATH_TAG "dbus-path"
#define MM_TYPE_MODEM (mm_modem_get_type ())
@@ -253,10 +242,6 @@ void mm_modem_set_charset (MMModem *self,
MMModemFn callback,
gpointer user_data);
-const char *mm_modem_charset_to_string (MMModemCharset charset);
-
-MMModemCharset mm_modem_charset_from_string (const char *string);
-
gboolean mm_modem_get_valid (MMModem *self);
char *mm_modem_get_device (MMModem *self);