#include #include "RilMonitor.h" #include "RilExceptions.h" #include "debug.h" void dumpsimfile(rilmonitor& m, int fileid) { try { int type=0; size_t itemcount=0, itemsize=0; requesthandler_ptr rs= m.GetSimRecordStatus(fileid, type, itemcount, itemsize); rs->wait(); if (rs->errorcode()) { //debug("file %04x : ril-ERROR %s\n", fileid, RilResultString(rs->errorcode()).c_str()); return; } requesthandler_ptr rc; if (type==RIL_SIMRECORDTYPE_CYCLIC || type==RIL_SIMRECORDTYPE_LINEAR) { debug("reading record %04x\n", fileid); for (size_t recnr=1 ; recnr<=itemcount ; recnr++) { try { rc= m.SendRestrictedSimCmd(RIL_SIMCMD_READRECORD, fileid, 3, recnr, 4, itemsize); rc->wait(); } catch(...) { debug("exception in sendrestrictedsimcmd\n"); } } } else if (type==RIL_SIMRECORDTYPE_TRANSPARENT) { debug("reading transparent %04x\n", fileid); rc= m.SendRestrictedSimCmd(RIL_SIMCMD_READBINARY, fileid, 3, 0, 0, itemsize); rc->wait(); } else if (type==RIL_SIMRECORDTYPE_DEDICATED || type==RIL_SIMRECORDTYPE_MASTER) { // this is for simfiles: 3f00, 7f10(DFTELECOM), 7f20(DFGSM) // todo : select DF, and enumerate contents. debug("todo: select DF\n"); } else { debug("unhandled simrecord type: %d\n", type); } } catch(ril_error& e) { debug("rilerr: %08lx: %s\n", e.err, e.name.c_str()); } catch(ril_structsize_error& e) { debug("rilsize: got %d, expected %d\n", e.got, e.expect); } catch(...) { debug("unknown exception\n"); } } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DebugSetLogfile("rilmon.log"); rilmonitor m; StringList args; if (!SplitString(ToString(lpCmdLine), args, false)) { error("Error in commandline"); return false; } std::vector reqfile; bool bFullRange= false; for (StringList::iterator i= args.begin() ; i!=args.end() ; ++i) { std::string& arg= *i; if (arg[0]=='-') switch(arg[1]) { case 'f': bFullRange=true; break; } else reqfile.push_back(strtoul(arg.c_str(), 0, 0)); } m.DumpDriverInfo(); long siglevel; requesthandler_ptr rl= m.GetSignalQuality(siglevel); rl->wait(); if (!rl->errorcode()) debug("signallevel: %d\n", siglevel); #if 0 eventqueue signal; m.SignalQualityEvent(signal); #endif if (bFullRange) { for (int fileid=0 ; fileid<0x10000 ; fileid++) dumpsimfile(m, fileid); } else if (reqfile.empty()) { for (int fileid=0x2f00 ; fileid<0x9000 ; fileid+=((fileid&0xfff)==0)?0xf00:1) { dumpsimfile(m, fileid); } } else { for (unsigned i=0 ; i