Loading the GPRS connectivity settings from a configuration file
This commit is contained in:
parent
a9a99d4ac1
commit
76d267e169
1
Makefile
1
Makefile
|
@ -71,6 +71,7 @@ dist:
|
|||
$(PACKAGE)-$(VERSION)/data/48x48/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/doc/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/doc/docbook.sh \
|
||||
$(PACKAGE)-$(VERSION)/doc/gprs.conf \
|
||||
$(PACKAGE)-$(VERSION)/doc/index.xml \
|
||||
$(PACKAGE)-$(VERSION)/doc/index.xsl \
|
||||
$(PACKAGE)-$(VERSION)/doc/manual.css.xml \
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
MKDIR = mkdir -m 0755 -p
|
||||
INSTALL = install
|
||||
RM = rm -f
|
||||
TARGETS = index.html phone.1 phone.html phonectl.1 phonectl.html
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
|
@ -36,11 +39,14 @@ install: $(TARGETS)
|
|||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "phone.html"
|
||||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "phonectl.1"
|
||||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -i -- "phonectl.html"
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/share/doc/Phone
|
||||
$(INSTALL) -m 0644 gprs.conf $(DESTDIR)$(PREFIX)/share/doc/Phone/gprs.conf
|
||||
|
||||
uninstall:
|
||||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "phone.1"
|
||||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "phone.html"
|
||||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "phonectl.1"
|
||||
./docbook.sh -P "$(DESTDIR)$(PREFIX)" -u -- "phonectl.html"
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/share/doc/Phone/gprs.conf
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
||||
|
|
4
doc/gprs.conf
Normal file
4
doc/gprs.conf
Normal file
|
@ -0,0 +1,4 @@
|
|||
[BASE DE]
|
||||
apn=internet.eplus.de
|
||||
username=eplus
|
||||
password=eplus
|
|
@ -1,5 +1,8 @@
|
|||
targets=index.html,phone.1,phone.html,phonectl.1,phonectl.html
|
||||
dist=Makefile,docbook.sh,index.xml,index.xsl,manual.css.xml,phone.css.xml,phone.xml,phonectl.css.xml,phonectl.xml,pppd-ip-down,pppd-ip-up,pppd-peers_phone
|
||||
dist=Makefile,docbook.sh,gprs.conf,index.xml,index.xsl,manual.css.xml,phone.css.xml,phone.xml,phonectl.css.xml,phonectl.xml,pppd-ip-down,pppd-ip-up,pppd-peers_phone
|
||||
|
||||
[gprs.conf]
|
||||
install=$(PREFIX)/share/doc/Phone
|
||||
|
||||
[index.html]
|
||||
type=script
|
||||
|
|
|
@ -164,7 +164,7 @@ debug.o: debug.c ../../include/Phone.h
|
|||
engineering.o: engineering.c ../../include/Phone.h
|
||||
$(CC) $(engineering_CFLAGS) -c engineering.c
|
||||
|
||||
gprs.o: gprs.c ../../include/Phone.h
|
||||
gprs.o: gprs.c ../../include/Phone.h ../../config.h
|
||||
$(CC) $(gprs_CFLAGS) -c gprs.c
|
||||
|
||||
gps.o: gps.c ../../include/Phone.h
|
||||
|
|
|
@ -22,6 +22,14 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <System.h>
|
||||
#include "Phone.h"
|
||||
#include "../../config.h"
|
||||
|
||||
#ifndef PREFIX
|
||||
# define PREFIX "/usr/local"
|
||||
#endif
|
||||
#ifndef SYSCONFDIR
|
||||
# define SYSCONFDIR PREFIX "/etc"
|
||||
#endif
|
||||
|
||||
|
||||
/* GPRS */
|
||||
|
@ -60,20 +68,6 @@ typedef struct _PhonePlugin
|
|||
#endif
|
||||
} GPRS;
|
||||
|
||||
typedef struct _GPRSOperator
|
||||
{
|
||||
char const * _operator;
|
||||
char const * apn;
|
||||
char const * username;
|
||||
char const * password;
|
||||
} GPRSOperator;
|
||||
|
||||
/* constants */
|
||||
static GPRSOperator _gprs_operators[] =
|
||||
{
|
||||
{ "BASE DE", "internet.eplus.de", "eplus", "eplus" }
|
||||
};
|
||||
|
||||
|
||||
/* prototypes */
|
||||
/* plug-in */
|
||||
|
@ -729,22 +723,26 @@ static int _gprs_load_defaults(GPRS * gprs)
|
|||
/* gprs_load_operator */
|
||||
static int _gprs_load_operator(GPRS * gprs, char const * _operator)
|
||||
{
|
||||
size_t i;
|
||||
GPRSOperator * o;
|
||||
Config * config;
|
||||
String const * p;
|
||||
|
||||
if(_operator == NULL)
|
||||
if((config = config_new()) == NULL)
|
||||
return -1;
|
||||
for(i = 0; i < sizeof(_gprs_operators) / sizeof(*_gprs_operators); i++)
|
||||
if(config_load(config, SYSCONFDIR "/" PACKAGE "/gprs.conf") != 0
|
||||
|| (p = config_get(config, _operator, "apn")) == NULL)
|
||||
{
|
||||
o = &_gprs_operators[i];
|
||||
if(strcmp(o->_operator, _operator) != 0)
|
||||
continue;
|
||||
gtk_entry_set_text(GTK_ENTRY(gprs->apn), o->apn);
|
||||
gtk_entry_set_text(GTK_ENTRY(gprs->username), o->username);
|
||||
gtk_entry_set_text(GTK_ENTRY(gprs->password), o->password);
|
||||
return 0;
|
||||
config_delete(config);
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
gtk_entry_set_text(GTK_ENTRY(gprs->apn), p);
|
||||
if((p = config_get(config, _operator, "username")) == NULL)
|
||||
p = "";
|
||||
gtk_entry_set_text(GTK_ENTRY(gprs->username), p);
|
||||
if((p = config_get(config, _operator, "password")) == NULL)
|
||||
p = "";
|
||||
gtk_entry_set_text(GTK_ENTRY(gprs->password), p);
|
||||
config_delete(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ sources=gprs.c
|
|||
install=$(LIBDIR)/Phone/plugins
|
||||
|
||||
[gprs.c]
|
||||
depends=../../include/Phone.h
|
||||
depends=../../include/Phone.h,../../config.h
|
||||
|
||||
[gps]
|
||||
type=plugin
|
||||
|
|
Loading…
Reference in New Issue
Block a user