*/
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <sys/stat.h>
+#ifdef UCLINUX
+/* <getopt.h> or "getopt.h" would include insufficient getopt.h from uClinux */
+#include "../getopt/getopt.h"
+#endif /* UCLINUX */
+
#ifndef VC6
#if defined(__svr4__) || defined(__FreeBSD__)
# include <strings.h> /* for bzero */
#include "gsm-common.h"
#include "gsm-api.h"
#include "gsm-networks.h"
+#ifndef UCLINUX
#include "gsm-ringtones.h"
#include "gsm-bitmaps.h"
#include "gsm-wap.h"
#include "gsm-sms.h"
#include "gsm-datetime.h"
+#endif /* UCLINUX */
#include "gsm-phonebook.h"
+#ifndef UCLINUX
#include "gsm-calendar.h"
+#endif /* UCLINUX */
#include "gsm-coding.h"
+#ifndef UCLINUX
#include "newmodules/n6110.h"
+#endif
#include "files/cfgreader.h"
+#ifndef UCLINUX
#include "files/gsm-filetypes.h"
+#endif /* UCLINUX */
#include "gnokii.h"
+#ifdef UCLINUX
+#include "data/virtmodem.h"
+#endif /* UCLINUX */
#ifdef USE_NLS
#include <locale.h>
#endif
-char *model; /* Model from .gnokiirc file. */
-char *Port; /* Port from .gnokiirc file */
-char *Initlength; /* Init length from .gnokiirc file */
-char *Connection; /* Connection type from .gnokiirc file */
+static char *model; /* Model from .gnokiirc file. */
+static char *Port; /* Port from .gnokiirc file */
+static char *Initlength; /* Init length from .gnokiirc file */
+static char *Connection; /* Connection type from .gnokiirc file */
+#ifndef UCLINUX
char *SynchronizeTime; /* If we set date and time from computer to phone (from .gnokiirc file) */
-char *BinDir; /* Binaries directory from .gnokiirc file - not used here yet */
+#endif /* UCLINUX */
+static char *BinDir; /* Binaries directory from .gnokiirc file - not used here yet */
-GSM_SMSMessage SMS[4];
+#ifndef UCLINUX
+static GSM_SMSMessage SMS[4];
+#endif /* UCLINUX */
+#ifndef UCLINUX
+
char *GetProfileCallAlertString(int code) {
switch (code) {
return BufferProfileGroups;
}
-char *print_error(GSM_Error e)
+static char *print_error(GSM_Error e)
{
// case GE_DEVICEOPENFAILED: return "Couldn't open specified serial device.";
}
}
-
GSM_Error GSM_ReadRingtoneFileOnConsole(char *FileName, GSM_Ringtone *ringtone)
{
GSM_Error error;
return 0;
}
-int GSM_SaveMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int argc, char *argv[],
+static int GSM_SaveMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int argc, char *argv[],
bool inter, bool unicode, bool profile, bool scale) {
int w,i;
GSM->PlayTone(255*255,0);
}
+#endif /* UCLINUX */
+
/* This function shows the copyright and some informations usefull for
debugging. */
-int version(void)
+static int version(void)
{
fprintf(stdout, _("GNOKII Version %s\n"
/* The function usage is only informative - it prints this program's usage and
command-line options. */
-int usage(void)
+static int usage(void)
{
- fprintf(stdout, _(" usage: gnokii [--help|--monitor [-noloop|-nl]|--version]\n"
+ fprintf(stdout, _(" usage: gnokii [--help] [--version]\n"
+ ));
+#ifndef UCLINUX
+" gnokii --monitor [-noloop|-nl]\n"
+ ));
+#endif /* UCLINUX */
+
+#ifndef UCLINUX
+ fprintf(stdout, _(
" gnokii --getmemory memory_type [start [end]] [-short|-v30|-v21|-v]\n"
+ ));
+#else /* UCLINUX */
+ fprintf(stdout, _(
+" gnokii --getmemory memory_type [start [end]] [-short]\n"
+ ));
+#endif /* UCLINUX */
+
+ fprintf(stdout, _(
" gnokii --writephonebook [-i]\n"
+ ));
+
+#ifndef UCLINUX
+ fprintf(stdout, _(
" gnokii --sendphonebookentry destination memory_type location\n"
" [--smsc message_center_number] [--smscno message_center_index]\n"
" [-s] [-v n] [-d]\n"
" [--smsc message_center_number] [--smscno message_center_index]\n"
" [-r] [-i] [-s] [-a] [--name name]\n"
" gnokii --getvoicemailbox\n"
+ ));
+#endif /* UCLINUX */
+
+ fprintf(stdout, _(
" gnokii --getspeeddial number\n"
" gnokii --setspeeddial number memory_type location\n\n"
+ ));
+#ifndef UCLINUX
+ fprintf(stdout, _(
" gnokii --getsms memory_type start [end] [-f file]\n"
" gnokii --getsmsstatus\n"
" gnokii --getsmsfolders\n"
" gnokii --sendprofile destination profile_name ringtonefile\n"
" picturefile [--smsc message_center_number]\n"
" [--smscno message_center_index] [-s] [-v n] [-d] [--scale]\n\n"
+ ));
+#endif /* UCLINUX */
+ fprintf(stdout, _(
" gnokii --reset [soft|hard]\n"
+ ));
+
+#ifndef UCLINUX
+ fprintf(stdout, _(
" gnokii --dialvoice number\n"
+ ));
+#endif /* UCLINUX */
+
+ fprintf(stdout, _(
" gnokii --cancelcall\n"
+ ));
+
+#ifndef UCLINUX
+ fprintf(stdout, _(
" gnokii --displayoutput\n"
" gnokii --presskeysequence sequence\n"
" gnokii --backupsettings file\n"
" gnokii --phonetests\n"
" gnokii --simlock\n"
" gnokii --getdisplaystatus\n"
+ ));
+#endif /* UCLINUX */
+
+ fprintf(stdout, _(
" gnokii --identify\n\n"
+ ));
+#ifndef UCLINUX
+ fprintf(stdout, _(
" gnokii --getwapbookmark location\n"
" gnokii --setwapbookmark title url [location]\n"
" gnokii --sendwapbookmark location destination\n"
));
#endif
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+ fprintf(stdout, _(
+" gnokii --gnokiid [--debug]\n"
+ ));
+#endif
+
return 0;
}
/* fbusinit is the generic function which waits for the FBUS link. The limit
is 10 seconds. After 10 seconds we quit. */
-void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
+static void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame))
{
int count=0;
#endif
/* Initialise the code for the GSM interface. */
- error = GSM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), rlp_handler, SynchronizeTime);
+ error = GSM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), rlp_handler, ""/*SynchronizeTime*/);
if (error != GE_NONE) {
fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
/* This function checks that the argument count for a given options is withing
an allowed range. */
-int checkargs(int opt, struct gnokii_arg_len gals[], int argc)
+static int checkargs(int opt, struct gnokii_arg_len gals[], int argc)
{
int i;
else return 1;
}
+static int gnokiid(int argc, char *argv[]);
+
/* Main function - handles command line arguments, passes them to separate
functions accordingly. */
{ "help", no_argument, NULL, OPT_HELP },// Display usage.
{ "version", no_argument, NULL, OPT_VERSION },// Display version and build information.
+#ifndef UCLINUX
{ "getsmsfolders", no_argument, NULL, OPT_GETSMSFOLDERS },// Gets SMS folders
{ "getsmsstatus", no_argument, NULL, OPT_GETSMSSTATUS },// Get SMS Folder Status
+#endif /* UCLINUX */
{ "identify", no_argument, NULL, OPT_IDENTIFY },// Identify
+#ifndef UCLINUX
{ "pmon", no_argument, NULL, OPT_PMON },// For development purposes: run in passive monitoring mode
{ "foogle", no_argument, NULL, OPT_FOOGLE },// For development purposes: insert you function calls here
{ "getdatetime", no_argument, NULL, OPT_GETDATETIME },// Get date and time mode
{ "getalarm", no_argument, NULL, OPT_GETALARM },// Get alarm
+#endif /* UCLINUX */
{ "cancelcall", no_argument, NULL, OPT_CANCELCALL },// Cancel Call
+#ifndef UCLINUX
{ "getdisplaystatus", no_argument, NULL, OPT_GETDISPLAYSTATUS },// Get display status mode
{ "allringtones", no_argument, NULL, OPT_ALLRINGTONES },/* Displays names of available ringtones */
{ "displayoutput", no_argument, NULL, OPT_DISPLAYOUTPUT },/* Show texts from phone's display */
{ "receivesms", no_argument, NULL, OPT_RECEIVESMS },
{ "setoperatorname", optional_argument, NULL, OPT_SETOPERATORNAME },/* Set downloaded operator name */
{ "setdatetime", optional_argument, NULL, OPT_SETDATETIME },// Set date and time
+#endif /* UCLINUX */
{ "writephonebook", optional_argument, NULL, OPT_WRITEPHONEBOOK },// Write phonebook (memory) mode
{ "reset", optional_argument, NULL, OPT_RESET },// Resets the phone
+#ifndef UCLINUX
{ "monitor", optional_argument, NULL, OPT_MONITOR },// Monitor mode
{ "setlogo", optional_argument, NULL, OPT_SETLOGO },// Set logo
{ "getprofile", optional_argument, NULL, OPT_GETPROFILE },// Show profile
{ "sendphonebookentry", required_argument, NULL, OPT_SENDPHONEBOOKENTRY},
{ "savephonebookentry", required_argument, NULL, OPT_SAVEPHONEBOOKENTRY},
{ "deletecalendarnote", required_argument, NULL, OPT_DELCALENDARNOTE },// Delete calendar note mode
+#endif /* UCLINUX */
{ "getmemory", required_argument, NULL, OPT_GETMEMORY },// Get memory mode
{ "getspeeddial", required_argument, NULL, OPT_GETSPEEDDIAL },// Get speed dial mode
{ "setspeeddial", required_argument, NULL, OPT_SETSPEEDDIAL },// Set speed dial mode
+#ifndef UCLINUX
{ "getsms", required_argument, NULL, OPT_GETSMS },// Get SMS message mode
{ "deletesms", required_argument, NULL, OPT_DELETESMS },// Delete SMS message mode
{ "sendsms", required_argument, NULL, OPT_SENDSMS },// Send SMS message mode
{ "sniff", optional_argument, NULL, OPT_SNIFFER },// Will show datas from port
{ "decodefile", required_argument, NULL, OPT_DECODEFILE },//decode input file
#endif
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+ { "gnokiid", optional_argument, NULL, OPT_GNOKIID },// gnokiid mode
+#endif /* UCLINUX */
{ 0, 0, 0, 0},
};
struct gnokii_arg_len gals[] =
{
+#ifndef UCLINUX
{ OPT_MONITOR, 0, 1, 0 },
#ifdef SECURITY
{ OPT_SAVEPHONEBOOKENTRY,2, 9, 0 },
{ OPT_SENDPHONEBOOKENTRY,3, 9, 0 },
{ OPT_DELCALENDARNOTE, 1, 1, 0 },
+#endif /* UCLINUX */
{ OPT_GETMEMORY, 2, 4, 0 },
{ OPT_GETSPEEDDIAL, 1, 1, 0 },
{ OPT_SETSPEEDDIAL, 3, 3, 0 },
+#ifndef UCLINUX
{ OPT_GETSMS, 2, 5, 0 },
{ OPT_DELETESMS, 2, 3, 0 },
{ OPT_SENDSMS, 1,10, 0 },
{ OPT_SETRINGTONE, 1, 3, 0 },
{ OPT_GETRINGTONE, 1, 2, 0 },
{ OPT_PRESSKEYSEQUENCE, 1, 1, 0 },
+#endif /* UCLINUX */
{ OPT_RESET, 0, 1, 0 },
+#ifndef UCLINUX
{ OPT_GETPROFILE, 0, 1, 0 },
{ OPT_SETPROFILE, 3, 3, 0 },
{ OPT_SENDPROFILE, 4,10, 0 },
+#endif /* UCLINUX */
{ OPT_WRITEPHONEBOOK, 0, 1, 0 },
+#ifndef UCLINUX
{ OPT_PLAYRINGTONE, 1, 1, 0 },
{ OPT_COMPOSER, 1, 1, 0 },
{ OPT_RINGTONECONVERT, 2, 2, 0 },
{ OPT_SAVEWAPSETTINGS, 1, 9, 0 },
{ OPT_SENDWAPSETTINGS, 2, 9, 0 },
{ OPT_DIVERT, 3, 5, 0 },
+#endif /* UCLINUX */
+
+#ifdef UCLINUX
+ { OPT_GNOKIID, 0, 1, 0 },
+#endif /* UCLINUX */
{ 0, 0, 0, 0 },
};
#endif
/* Read config file */
- if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, &SynchronizeTime,false) < 0) {
+ if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, false) < 0) {
exit(-1);
}
// Then, options with no arguments
case OPT_HELP: rc = usage(); break;
case OPT_VERSION: rc = version(); break;
+#ifndef UCLINUX
case OPT_MONITOR: rc = monitormode(nargc, nargv); break;
case OPT_GETSMSFOLDERS: rc = getsmsfolders(); break;
case OPT_GETDATETIME: rc = getdatetime(); break;
case OPT_GETALARM: rc = getalarm(); break;
case OPT_GETDISPLAYSTATUS: rc = getdisplaystatus(); break;
case OPT_PMON: rc = pmon(); break;
+#endif /* UCLINUX */
case OPT_WRITEPHONEBOOK: rc = writephonebook(nargc, nargv);break;
+#ifndef UCLINUX
#ifdef SECURITY
case OPT_ENTERSECURITYCODE: rc = entersecuritycode(optarg); break;
case OPT_GETSECURITYCODESTATUS: rc = getsecuritycodestatus(); break;
case OPT_SETDATETIME: rc = setdatetime(nargc, nargv); break;
case OPT_SETALARM: rc = setalarm(nargv); break;
case OPT_DIALVOICE: rc = dialvoice(optarg); break;
+#endif /* UCLINUX */
case OPT_CANCELCALL: rc = cancelcall(); break;
+#ifndef UCLINUX
case OPT_GETCALENDARNOTE: rc = getcalendarnote(nargc, nargv);break;
case OPT_DELCALENDARNOTE: rc = deletecalendarnote(optarg);break;
case OPT_SAVECALENDARNOTE: rc = savecalendarnote(nargc, nargv);break;
case OPT_SAVEPHONEBOOKENTRY: rc = savephonebookentry(nargc, nargv);break;
case OPT_SENDPHONEBOOKENTRY: rc = sendphonebookentry(nargc, nargv);break;
case OPT_WRITECALENDARNOTE: rc = writecalendarnote(nargv); break;
+#endif /* UCLINUX */
case OPT_GETMEMORY: rc = getmemory(nargc, nargv); break;
case OPT_GETSPEEDDIAL: rc = getspeeddial(optarg); break;
case OPT_SETSPEEDDIAL: rc = setspeeddial(nargv); break;
+#ifndef UCLINUX
case OPT_GETSMS: rc = getsms(argc, argv); break;
case OPT_GETSMSSTATUS: rc = getsmsstatus(argc, argv); break;
case OPT_DELETESMS: rc = deletesms(nargc, nargv); break;
case OPT_GETSMSC: rc = getsmsc(optarg); break;
case OPT_RENAMESMSC: rc = renamesmsc(nargc,nargv); break;
case OPT_NETMONITOR: rc = netmonitor(optarg); break;
+#endif /* UCLINUX */
case OPT_IDENTIFY: rc = identify(); break;
+#ifndef UCLINUX
case OPT_SETLOGO: rc = setlogo(nargc, nargv); break;
case OPT_GETLOGO: rc = getlogo(nargc, nargv); break;
case OPT_RECEIVESMS: rc = receivesms(nargc, nargv); break;
case OPT_PHONETESTS: rc = phonetests(); break;
case OPT_SIMLOCKINFO: rc = simlockinfo(); break;
case OPT_SENDDTMF: rc = senddtmf(optarg); break;
+#endif /* UCLINUX */
case OPT_RESET: rc = reset(nargc,nargv); break;
+#ifndef UCLINUX
case OPT_GETOPERATORNAME: rc = getoperatorname(); break;
case OPT_SETOPERATORNAME: rc = setoperatorname(nargc,nargv);break;
case OPT_GETWAPBOOKMARK: rc = getwapbookmark(nargc,nargv);break;
case OPT_GETVOICEMAILBOX: rc = getvoicemailbox(); break;
case OPT_NM_COLLECT: rc = nm_collect(nargc, nargv); break;
case OPT_NETMONITORDATA: rc = netmonitordata(nargc, nargv);break;
+#endif /* UCLINUX */
+#ifdef UCLINUX
+ case OPT_GNOKIID: rc = gnokiid(nargc, nargv); break;
+#endif /* UCLINUX */
default: fprintf(stderr, _("Unknown option: %d\n"), c); break;
}
exit(-1);
}
+#ifndef UCLINUX
+
/* Restores various phone settings from one file */
int restoresettings(char *argv[])
{
case GSM_DisableFax:
case GSM_EnableEmail:
case GSM_DisableEmail:
- fprintf(stdout,_("Warning: saving %i chars\n"),strlen(MultiSMS.SMS[0].MessageText));
+ fprintf(stdout,_("Warning: saving %ld chars\n"),(long)strlen(MultiSMS.SMS[0].MessageText));
msgnum=1;
break;
default:
case GSM_DisableFax:
case GSM_EnableEmail:
case GSM_DisableEmail:
- fprintf(stdout,_("Warning: saving %i chars\n"),strlen(MultiSMS.SMS[0].MessageText));
+ fprintf(stdout,_("Warning: saving %ld chars\n"),(long)strlen(MultiSMS.SMS[0].MessageText));
msgnum=1;
break;
default:
return 0;
}
+#endif /* UCLINUX */
+
/* Cancel a call */
-int cancelcall(void)
+static int cancelcall(void)
{
fbusinit(NULL);
return 0;
}
+#ifndef UCLINUX
+
int savelogo(int argc, char *argv[])
{
GSM_Bitmap bitmap;
} else {
GSM->SetBitmap(&bitmap);
GSM->GetBitmap(&oldbit);
- fprintf(stderr, _("too long, truncated to \"%s\" (length %i)\n"),oldbit.text,strlen(oldbit.text));
+ fprintf(stderr, _("too long, truncated to \"%s\" (length %ld)\n"),oldbit.text,(long)strlen(oldbit.text));
}
ok=false;
}
return 0;
}
+#endif /* UCLINUX */
+
+/* Emulation of separate gnokiid binary for uClinux */
+
+#ifdef UCLINUX
+
+static int gnokiid(int argc, char *argv[])
+{
+ bool DebugMode; /* When true, run in debug mode */
+ char *Model; /* Model from .gnokiirc file. */
+ char *Port; /* Port from .gnokiirc file */
+ char *Initlength; /* Init length from .gnokiirc file */
+ char *Connection; /* Connection type from .gnokiirc file */
+ char *BinDir; /* Directory of the mgnokiidev command */
+
+ /* evaluate for presence of "--debug" argument in parameter */
+ DebugMode = false;
+ if(argc>0)
+ {
+ if( strcmp(argv[0],"--debug" ))
+ {
+ usage();
+ return -1;
+ }
+ else
+ DebugMode = true;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, _("Entering gnokiid mode...\n"));
+#endif
+
+ if (CFG_ReadConfig(&Model, &Port, &Initlength, &Connection, &BinDir, true) < 0)
+ return(-1);
+
+ if (VM_Initialise(Model, Port, Initlength, GCT_FBUS, BinDir, DebugMode, true, ""/*SynchronizeTime*/) == false)
+ return (-1);
+
+ VM_Terminate();
+
+ return 0;
+}
+
+#endif /* UCLINUX */
+
+#ifndef UCLINUX
+
/* Shows texts from phone's display */
int displayoutput()
}
+#endif /* UCLINUX */
+
/* Get requested range of memory storage entries and output to stdout in
easy-to-parse format */
-int getmemory(int argc, char *argv[])
+static int getmemory(int argc, char *argv[])
{
GSM_PhonebookEntry entry;
i_used++;
else if (do_all)
break;
+#ifndef UCLINUX
if (output_opt && !strcmp( output_opt,"-v30")) {
semicolon_pipe_substitution( &entry, 0 );
fprintf(stdout,_("%s"),GSM_GetVCARD(&entry,30));
fprintf(stdout,_("%s"),GSM_GetVCARD(&entry,10));
formatdone=true;
}
+#endif /* UCLINUX */
if (output_opt && !strcmp(output_opt,"-short")) {
semicolon_pipe_substitution( &entry, 0 );
fprintf(stdout, "%s;%s;%s;%d;%d;", entry.Name, entry.Number, memory_type_string, entry.Location, entry.Group);
/* Read data from stdin, parse and write to phone. The parsing is relatively
crude and doesn't allow for much variation from the stipulated format. */
-int writephonebook(int argc, char *args[])
+static int writephonebook(int argc, char *args[])
{
GSM_PhonebookEntry entry;
/* Getting speed dials. */
-int getspeeddial(char *Number) {
+static int getspeeddial(char *Number) {
GSM_SpeedDial entry;
GSM_Error error;
/* Setting speed dials. */
-int setspeeddial(char *argv[]) {
+static int setspeeddial(char *argv[]) {
GSM_SpeedDial entry;
return 0;
}
+#ifndef UCLINUX
+
/* Getting the status of the display. */
int getdisplaystatus()
return 0;
}
-int identify( void )
+#endif /* UCLINUX */
+
+static int identify( void )
{
/* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */
char imei[64], model[64], rev[64], manufacturer[64];
return 0;
}
+#ifndef UCLINUX
+
int senddtmf(char *String)
{
return 0;
}
+#endif /* UCLINUX */
+
/* Resets the phone */
-int reset(int argc, char *argv[])
+static int reset(int argc, char *argv[])
{
unsigned char _type=0x03;
return 0;
}
+#ifndef UCLINUX
+
/* This is a "convenience" function to allow quick test of new API stuff which
doesn't warrant a "proper" command line function. */
/* Initialise the code for the GSM interface. */
- error = GSM_Initialise(model, Port, Initlength, connection, RLP_DisplayF96Frame, SynchronizeTime);
+ error = GSM_Initialise(model, Port, Initlength, connection, RLP_DisplayF96Frame, ""/*SynchronizeTime*/);
if (error != GE_NONE) {
fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n"));
return 0;
}
+#endif /* UCLINUX */
+
/*
* Returns number of sostituited characters.
* ... may be useful one day ??
*/
-int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction )
+static int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction )
/* direction = 0 : after reading phone memory (
* 1 : writing phone memory
*/
return( i_sost );
}
+#ifndef UCLINUX
+
+extern GSM_Error N6110_EnableExtendedCommands (unsigned char status);
+
/* Allows to set simlock state.
With older phone (older 51xx, 61xx) can open them, with older
and newer should be able to close them */
case GE_NONE:
/* Put entry into SMS structure */
+#ifndef UCLINUX
if (GetModelFeature(FN_PHONEBOOK)==F_PBK71) {
GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21);
- } else {
+ } else
+#endif /* UCLINUX */
+ {
GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10);
}
return 0;
}
+
+#endif /* UCLINUX */