⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsm_event.cc

📁 对各种手机进行编程的工具包源码gsmlib 1.9版本。
💻 CC
字号:
// *************************************************************************// * GSM TA/ME library// *// * File:    gsm_event.cc// *// * Purpose: Event handler interface// *// * Author:  Peter Hofmann (software@pxh.de)// *// * Created: 7.6.1999// *************************************************************************#ifdef HAVE_CONFIG_H#include <gsm_config.h>#endif#include <gsmlib/gsm_nls.h>#include <gsmlib/gsm_event.h>#include <gsmlib/gsm_parser.h>#include <gsmlib/gsm_at.h>#include <gsmlib/gsm_me_ta.h>using namespace std;using namespace gsmlib;// GsmEvent membersvoid GsmEvent::dispatch(string s, GsmAt &at) throw(GsmException){  SMSMessageType messageType;  bool indication = false;  if (s.substr(0, 5) == "+CMT:")    messageType = NormalSMS;  else if (s.substr(0, 5) == "+CBM:")    messageType = CellBroadcastSMS;  else if (s.substr(0, 5) == "+CDS:")  {    // workaround for phones that report CDS when they actually mean CDSI    indication = at.getMeTa().getCapabilities()._CDSmeansCDSI;    messageType = StatusReportSMS;  }  else if (s.substr(0, 6) == "+CMTI:")  {    indication = true;    messageType = NormalSMS;  }  else if (s.substr(0, 6) == "+CBMI:")  {    indication = true;    messageType = CellBroadcastSMS;  }  else if (s.substr(0, 6) == "+CDSI:")  {    indication = true;    messageType = StatusReportSMS;  }  else if (s.substr(0, 4) == "RING")  {    ringIndication();    return;  }  else if (s.substr(0, 6) == "+CLIP:")  {    //    <number>,<type>[,<subaddr>,<satype>[,<alpha>]]    s = s.substr(6);    Parser p(s);    string num = p.parseString();    p.parseComma();    unsigned int numberFormat;    if ((numberFormat = p.parseInt()) == InternationalNumberFormat)      num = "+" + num;    else if (numberFormat != UnknownNumberFormat)      throw GsmException(stringPrintf(_("unexpected number format %d"),                                      numberFormat), OtherError);    string subAddr;    string alpha;    if (p.parseComma(true))    {      subAddr = p.parseString(true);      p.parseComma();      p.parseInt(true);         // FIXME subaddr type ignored      if (p.parseComma(true))        alpha = p.parseString(true);    }        // call the event handler    callerLineID(num, subAddr, alpha);    return;  }  else    throw GsmException(stringPrintf(_("unexpected unsolicited event '%s'"),                                    s.c_str()), OtherError);  if (indication)  {    // handle SMS storage indication    s = s.substr(6);    Parser p(s);    string storeName = p.parseString();    p.parseComma();    unsigned int index = p.parseInt();    SMSReceptionIndication(storeName, index - 1, messageType);  }  else    if (messageType == CellBroadcastSMS)    {      // handle CB message      string pdu = at.getLine();      CBMessageRef cb = new CBMessage(pdu);      // call the event handler      CBReception(cb);    }    else    {      // handle SMS      string pdu = at.getLine();            // add missing service centre address if required by ME      if (! at.getMeTa().getCapabilities()._hasSMSSCAprefix)      pdu = "00" + pdu;            SMSMessageRef sms = SMSMessage::decode(pdu);            // send acknowledgement if necessary      if (at.getMeTa().getCapabilities()._sendAck)        at.chat("+CNMA");            // call the event handler      SMSReception(sms, messageType);    }}void GsmEvent::callerLineID(string number, string subAddr, string alpha){  // ignore event}void GsmEvent::SMSReception(SMSMessageRef newMessage,                            SMSMessageType messageType){  // ignore event}void GsmEvent::CBReception(CBMessageRef newMessage){  // ignore event}void GsmEvent::SMSReceptionIndication(string storeName, unsigned int index,                                      SMSMessageType messageType){  // ignore event}void GsmEvent::ringIndication(){  // ignore event}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -