[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] Additional programs and language bindings branch, master, updated.
From: |
Daniele Forsi |
Subject: |
[SCM] Additional programs and language bindings branch, master, updated. c9f81a0de41b653505e65f6b2a8a067ab33e4308 |
Date: |
Sun, 01 Jul 2012 17:12:06 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Additional programs and language bindings".
The branch, master has been updated
via c9f81a0de41b653505e65f6b2a8a067ab33e4308 (commit)
from 090fd7edadebffe651d9096cfb78d601733c9463 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii/gnokii-extras.git/commit/?id=c9f81a0de41b653505e65f6b2a8a067ab33e4308
commit c9f81a0de41b653505e65f6b2a8a067ab33e4308
Author: Daniele Forsi <address@hidden>
Date: Sun Jul 1 19:07:38 2012 +0200
Add ringtone/getallringtones
diff --git a/snippets/Makefile b/snippets/Makefile
index e324465..8ddfdc0 100644
--- a/snippets/Makefile
+++ b/snippets/Makefile
@@ -1,7 +1,7 @@
# $Id$
# Makefile for gnokii snippets
-DIRS += calendar internals misc mms monitor other phonebook sms
+DIRS += calendar internals misc mms monitor other phonebook ringtone sms
all: $(DIRS)
diff --git a/snippets/README b/snippets/README
index dcd76ce..2f5424b 100644
--- a/snippets/README
+++ b/snippets/README
@@ -1,5 +1,3 @@
-$Id$
-
The directory tree is made after the division of commandline gnokii, with the
additions of "internals" and "misc".
For example in the "other" directory you can find code similar to that found
in gnokii-other.c
@@ -22,6 +20,9 @@ For example in the "other" directory you can find code
similar to that found in
* phonebook
how to deal with the phonebook
+* ringtone
+ how to deal with ringtones
+
* sms
how to deal with short messages
diff --git a/snippets/ringtone/.gitignore b/snippets/ringtone/.gitignore
new file mode 100644
index 0000000..5e26102
--- /dev/null
+++ b/snippets/ringtone/.gitignore
@@ -0,0 +1 @@
+getallringtones
diff --git a/snippets/ringtone/Makefile b/snippets/ringtone/Makefile
new file mode 100644
index 0000000..7adeafc
--- /dev/null
+++ b/snippets/ringtone/Makefile
@@ -0,0 +1,4 @@
+PROGS = getallringtones
+
+TOPDIR = ..
+include ${TOPDIR}/Makefile.global
diff --git a/snippets/ringtone/getallringtones.c
b/snippets/ringtone/getallringtones.c
new file mode 100644
index 0000000..02b13fb
--- /dev/null
+++ b/snippets/ringtone/getallringtones.c
@@ -0,0 +1,129 @@
+/*
+
+ G N O K I I
+
+ A Linux/Unix toolset and driver for the mobile phones.
+
+ This file is part of gnokii.
+
+ Gnokii 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.
+
+ Gnokii 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 gnokii; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Copyright (C) 2012 by Daniele Forsi
+
+ Tries to read all ringtones from 0 to 999 and saves them in raw format.
+ This doesn't use GN_OP_GetRingtoneList because it only shows location 100
+ on Series 40 3rd, as of gnokii 0.6.31, but more ringtones are available.
+
+ compile with
+ gcc -Wall -o getallringtones getallringtones.c `pkg-config --libs gnokii`
+
+ usage:
+ getallringtones --overwrite
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+
+#include <gnokii.h>
+
+/* prepare for i18n */
+#define _(x) x
+
+struct gn_statemachine *state = NULL;
+
+void busterminate(void) {
+ gn_lib_phone_close(state);
+ gn_lib_phoneprofile_free(&state);
+ gn_lib_library_free();
+}
+
+void businit(void) {
+ gn_error error;
+
+ atexit(busterminate);
+
+ error = gn_lib_phoneprofile_load(NULL, &state);
+ if (GN_ERR_NONE == error) {
+ error = gn_lib_phone_open(state);
+ }
+
+ if (GN_ERR_NONE != error) {
+ fprintf(stderr, "%s\n", gn_error_print(error));
+ exit(-1);
+ }
+}
+
+void signal_handler(int signal) {
+ (void)signal;
+
+ exit(-2);
+}
+
+int main(int argc, char *argv[]) {
+ gn_data data;
+ gn_error error;
+ gn_ringtone ringtone;
+ gn_raw_data rawdata;
+ unsigned char buff[65536];
+ FILE *fp;
+
+ if (argc != 2 || strcmp(argv[1], "--overwrite")) {
+ fprintf(stderr, _("Usage: %s --overwrite\nPurpose: print a list
of ringtones and write each one in a file\n"), argv[0]);
+ fprintf(stderr, _("WARNING: files with the same name are
overwritten without asking\n"));
+ exit(-1);
+ }
+
+ businit();
+
+ signal(SIGINT, signal_handler);
+
+ memset(&ringtone, 0, sizeof(ringtone));
+ rawdata.data = buff;
+ gn_data_clear(&data);
+ data.ringtone = &ringtone;
+ data.raw_data = &rawdata;
+
+ printf(_("#\tbytes\tname\n"));
+ for (ringtone.location = 1; ringtone.location < 1000;
ringtone.location++) {
+ /* Set length every time because it is overwritten in
GN_OP_GetRawRingtone */
+ rawdata.length = sizeof(buff);
+ error = gn_sm_functions(GN_OP_GetRawRingtone, &data, state);
+ switch (error) {
+ case GN_ERR_NONE:
+ printf(_("%3d\t%5d\t%s\n"), ringtone.location,
rawdata.length, ringtone.name);
+ fp = fopen(ringtone.name, "w");
+ if (fp) {
+ fwrite(rawdata.data, rawdata.length, 1, fp);
+ fclose(fp);
+ } else {
+ perror(argv[0]);
+ }
+ break;
+ case GN_ERR_INVALIDSIZE:
+ printf(_("%3d\t%5d\t*** %s\n"), ringtone.location,
rawdata.length, gn_error_print(error));
+ break;
+ case GN_ERR_INVALIDLOCATION:
+ /* Always ignore? On Nokia 5300 locations 80-98 are
invalid but 99 and 100 are valid */
+ break;
+ default:
+ break;
+ }
+ }
+
+ exit(GN_ERR_NONE);
+}
diff --git a/snippets/ringtone/getallringtones.readme
b/snippets/ringtone/getallringtones.readme
new file mode 100644
index 0000000..e6d5b8e
--- /dev/null
+++ b/snippets/ringtone/getallringtones.readme
@@ -0,0 +1,8 @@
+Dumps some information about ringtones stored in the phone and writes the raw
+contents of each one in the current directory.
+Uses GN_OP_GetRawRingtone.
+
+WARNING: existing files with the same name are overwritten without asking.
+
+Usage:
+$ getallringtones --overwrite
-----------------------------------------------------------------------
Summary of changes:
snippets/Makefile | 2 +-
snippets/README | 5 +-
snippets/ringtone/.gitignore | 1 +
snippets/{sms => ringtone}/Makefile | 4 +-
.../getallringtones.c} | 89 ++++++++++----------
snippets/ringtone/getallringtones.readme | 8 ++
6 files changed, 59 insertions(+), 50 deletions(-)
create mode 100644 snippets/ringtone/.gitignore
copy snippets/{sms => ringtone}/Makefile (63%)
copy snippets/{phonebook/phonebook_status.c => ringtone/getallringtones.c}
(50%)
create mode 100644 snippets/ringtone/getallringtones.readme
hooks/post-receive
--
Additional programs and language bindings
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] Additional programs and language bindings branch, master, updated. c9f81a0de41b653505e65f6b2a8a067ab33e4308,
Daniele Forsi <=