Logo Search packages:      
Sourcecode: gabber version File versions  Download package

Message::Message ( const Element t  ) 

Construct a message based upon the given judo::Element.

See also:
judo::Element
Parameters:
t A judo::Element which should have a message base element

Definition at line 37 of file jabberoo-message.cc.

References jabberoo::Packet::addX(), jabberoo::Packet::findX(), judo::Element::getAttrib(), getDateTime(), and jabberoo::Packet::getFrom().

Referenced by replyTo().

     : Packet(t)
{
     // Determine message type..
     _type = translateType(t.getAttrib("type"));

#ifndef WIN32
     Element *x;
     string date;

     x = findX("jabber:x:delay");
     if (x) 
     {
        date = x->getAttrib("stamp");
        if (!date.empty()) 
        {
             struct tm ts;
             memset(&ts, 0, sizeof(struct tm));
             sscanf(date.c_str(), "%04d%02d%02dT%02d:%02d:%02d", &ts.tm_year, &ts.tm_mon, &ts.tm_mday, 
                  &ts.tm_hour, &ts.tm_min, &ts.tm_sec);
             ts.tm_year -= 1900;
             ts.tm_mon -= 1;
             // ok, lets make this time local
#ifdef HAVE_TIMEGM
             tzset(); // this should be called in the beginning anyways..
             ts.tm_hour += timezone;
             _timestamp = timegm(&ts); 
#else // HAVE_TIMEGM
             char *tz = getenv("TZ");
             setenv("TZ", "", 1);
             tzset();
             _timestamp = mktime(&ts);
             if (tz)
                 setenv("TZ", tz, 1);
             else
                 unsetenv("TZ");
             tzset();
#endif // HAVE_TIMEGM
             return;
        }
     }
     // Otherwise we want to get the current time
     _timestamp = time(0);
     // And now we'll add the XML for it in case the XML of this message
     // is logged or passed on
     x = addX("jabber:x:delay");
     x->putAttrib("from", getFrom());
     x->putAttrib("stamp", getDateTime("%Y%m%dT%H:%M:%S%z"));
#endif     
}


Generated by  Doxygen 1.6.0   Back to index