コード例 #1
0
void ICQClientPrivate::processMsgQueueSMS()
{
    list<ICQEvent*>::iterator it;
    for (it = msgQueue.begin(); it != msgQueue.end();){
        if ((sock == NULL) || (sock->isError())) return;
        ICQEvent *e = *it;
        if (e->message() == NULL){
            it++;
            continue;
        }
        if (e->message()->Type() != ICQ_MSGxSMS){
            it++;
            continue;
        }
        ICQSMS *msg = static_cast<ICQSMS*>(e->message());
        XmlBranch xmltree("icq_sms_message");
        string destination = "+";
        for (const char *p = msg->Phone.c_str(); *p; p++){
            if ((*p >= '0') && (*p <= '9'))
                destination += *p;
        }
        string text = msg->Message.c_str();
        client->translate("utf8", msg->Charset.c_str(), text);
        text = client->clearHTML(text);
        string sender = client->owner->name(true);
        char uin[13];
        snprintf(uin, sizeof(uin), "%lu", client->owner->Uin);
        xmltree.pushnode(new XmlLeaf("destination",destination));
        xmltree.pushnode(new XmlLeaf("text",text));
        xmltree.pushnode(new XmlLeaf("codepage","1252"));
        xmltree.pushnode(new XmlLeaf("encoding","utf8"));
        xmltree.pushnode(new XmlLeaf("senders_UIN",uin));
        xmltree.pushnode(new XmlLeaf("senders_name",sender));
        xmltree.pushnode(new XmlLeaf("delivery_receipt","Yes"));

        /* Time string, format: Wkd, DD Mnm YYYY HH:MM:SS TMZ */
        char timestr[30];
        time_t t;
        struct tm *tm;
        time(&t);
        tm = gmtime(&t);

        snprintf(timestr, sizeof(timestr), "%s, %02u %s %04u %02u:%02u:%02u GMT",
                 w_days[tm->tm_wday], tm->tm_mday, months[tm->tm_mon], tm->tm_year + 1900,
                 tm->tm_hour, tm->tm_min, tm->tm_sec);
        xmltree.pushnode(new XmlLeaf("time",string(timestr)));
        string xmlstr = xmltree.toString(0);

        serverRequest(ICQ_SRVxREQ_MORE);
        sock->writeBuffer << ICQ_SRVxREQ_SEND_SMS
        << 0x00010016L << 0x00000000L << 0x00000000L
        << 0x00000000L << 0x00000000L << (unsigned long)(xmlstr.size());
        sock->writeBuffer << xmlstr.c_str();
        sendServerRequest();
        msgQueue.remove(e);
        e->m_nId = m_nMsgSequence;
        varEvents.push_back(e);
        it = msgQueue.begin();
    }
}
コード例 #2
0
void ICQClient::processMsgQueueSMS()
{
    list<ICQEvent*>::iterator it;
    for (it = msgQueue.begin(); it != msgQueue.end();){
        ICQEvent *e = *it;
        if (e->message() == NULL){
            it++;
            continue;
        }
        if (e->message()->Type() != ICQ_MSGxSMS){
            it++;
            continue;
        }
        ICQSMS *msg = static_cast<ICQSMS*>(e->message());
        XmlBranch xmltree("icq_sms_message");
        string destination = "+";
        for (const char *p = msg->Phone.c_str(); *p; p++){
            if ((*p >= '0') && (*p <= '9'))
                destination += *p;
        }
        string text = clearHTML(msg->Message.c_str());
        toUTF(text);
        string sender = name(true);
        char uin[13];
        snprintf(uin, sizeof(uin), "%lu", Uin());
        xmltree.pushnode(new XmlLeaf("destination",destination));
        xmltree.pushnode(new XmlLeaf("text",text));
        xmltree.pushnode(new XmlLeaf("codepage","1252"));
        xmltree.pushnode(new XmlLeaf("encoding","urf8"));
        xmltree.pushnode(new XmlLeaf("senders_UIN",uin));
        xmltree.pushnode(new XmlLeaf("senders_name",sender));
        xmltree.pushnode(new XmlLeaf("delivery_receipt","Yes"));

        /* Time string, format: Wkd, DD Mnm YYYY HH:MM:SS TMZ */
        char timestr[30];
        time_t t;
        struct tm *tm;
        time(&t);
        tm = gmtime(&t);
        strftime(timestr, 30, "%a, %d %b %Y %T %Z", tm);
        xmltree.pushnode(new XmlLeaf("time",string(timestr)));
        string xmlstr = xmltree.toString(0);

        serverRequest(ICQ_SRVxREQ_MORE);
        writeBuffer << ICQ_SRVxREQ_SEND_SMS
        << 0x00010016L << 0x00000000L << 0x00000000L
        << 0x00000000L << 0x00000000L << (unsigned long)(xmlstr.size());
        writeBuffer << xmlstr.c_str();
        sendServerRequest();
        msgQueue.remove(e);
        e->m_nId = m_nMsgSequence;
        varEvents.push_back(e);
        it = msgQueue.begin();
    }
}
コード例 #3
0
ファイル: xml2pib.c プロジェクト: GSLyons/open-plc-utils
int main (int argc, char const * argv [])

{
	static char const * optv [] =
	{
		"f:qv",
		"pib-file [pib-file] [...]",
		"Qualcomm Atheros PLC Parameter File Editor",
		"f f\txmlfile is (f)",
		"q\tquiet",
		"v\tverbose",
		(char const *) (0)
	};
	struct node * node = (struct node *)(0);
	flag_t flags = (flag_t)(0);
	signed c;
	optind = 1;
	while ((c = getoptv (argc, argv, optv)) != -1)
	{
		switch (c)
		{
		case 'f':
			node = xmlopen (optarg);
			break;
		case 'm':
			_setbits (flags, PIB_MANIFEST);
			break;
		case 'q':
			_setbits (flags, PIB_SILENCE);
			break;
		case 'v':
			_setbits (flags, PIB_VERBOSE);
			break;
		default:
			break;
		}
	}
	argc -= optind;
	argv += optind;
	while ((argc) && (* argv))
	{
		function (* argv, node);
		argc--;
		argv++;
	}
	if (_anyset (flags, PIB_VERBOSE))
	{
		xmltree (node);
	}
	xmlfree (node);
	return (0);
}
コード例 #4
0
ファイル: xmltree.c プロジェクト: tcdog001/apv5sdk-v15
void xmltree (NODE const * node) 

{
	if (node) 
	{
		node = node->below;
	}
	while (node) 
	{
		static unsigned level = 0;
		printf ("%03d ", node->line);
		printf ("(%c) ", node->type);
		output (level, "[%s]", node->text);
		level++;
		xmltree (node);
		level--;
		node = node->after;
	}
	return;
}