summaryrefslogtreecommitdiff
path: root/symbian/ext/Moped/Msg/Msg.xs
blob: ae47e0a556f584a9e3f656796bf3b44b0ba69b11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <eikenv.h>
#include <e32std.h>

#include "etelbgsm.h" // From Symbian 6.1 SDK (the Communicator SDK)

#ifdef __cplusplus
extern "C" {
#endif
#include "PerlBase.h"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif

_LIT(KTsyName, "phonetsy.tsy");

#define XS_SYMBIAN_OR_EMPTY(e, c) errno = (e) = (c); if ((e) != KErrNone) XSRETURN_EMPTY

MODULE = Moped::Msg	PACKAGE = Moped::Msg

PROTOTYPES: ENABLE

extern "C" void
get_gsm_network_info()
    PREINIT:
	TInt			error;
	TInt			enumphone;
	RTelServer		server;
	RBasicGsmPhone		phone;
	RTelServer::TPhoneInfo	info;
	MBasicGsmPhoneNetwork::TCurrentNetworkInfo networkinfo;
    PPCODE:
	if (GIMME != G_ARRAY)
	    XSRETURN_UNDEF;
	XS_SYMBIAN_OR_EMPTY(error, server.Connect());
	XS_SYMBIAN_OR_EMPTY(error, server.LoadPhoneModule(KTsyName));
	XS_SYMBIAN_OR_EMPTY(error, server.EnumeratePhones(enumphone));
	if (enumphone < 1)
	    XSRETURN_EMPTY;
	XS_SYMBIAN_OR_EMPTY(error, server.GetPhoneInfo(0, info));
	XS_SYMBIAN_OR_EMPTY(error, phone.Open(server, info.iName));
	XS_SYMBIAN_OR_EMPTY(error, phone.GetCurrentNetworkInfo(networkinfo));
	EXTEND(SP, 4);
	PUSHs(sv_2mortal(newSViv(networkinfo.iNetworkInfo.iId.iMCC)));
	PUSHs(sv_2mortal(newSViv(networkinfo.iNetworkInfo.iId.iMNC)));
	PUSHs(sv_2mortal(newSViv(networkinfo.iLocationAreaCode)));
	PUSHs(sv_2mortal(newSViv(networkinfo.iCellId)));