Document Xtra Status GUIDs in oscartypes.h.
[kdenetwork.git] / kopete / protocols / oscar / liboscar / xtrazxawayservice.cpp
blob272fd452dfed0e1fc5dddc42c27c5cb4a3c6c8c5
1 /*
2 Kopete Oscar Protocol
3 xtrazxawayservice.cpp - Xtraz XAwayService
5 Copyright (c) 2007 Roman Jarosz <kedgedev@centrum.cz>
7 Kopete (c) 2007 by the Kopete developers <kopete-devel@kde.org>
9 *************************************************************************
10 * *
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of the GNU Lesser General Public *
13 * License as published by the Free Software Foundation; either *
14 * version 2 of the License, or (at your option) any later version. *
15 * *
16 *************************************************************************
19 #include "xtrazxawayservice.h"
21 namespace Xtraz
24 XAwayService::XAwayService()
25 : XService()
30 void XAwayService::setSenderId( const QString& uni )
32 m_senderId = uni;
35 QString XAwayService::senderId() const
37 return m_senderId;
40 void XAwayService::setIconIndex( int index )
42 m_iconIndex = index + 1;
45 int XAwayService::iconIndex() const
47 return m_iconIndex - 1;
50 void XAwayService::setTitle( const QString& title )
52 m_title = title;
55 QString XAwayService::title() const
57 return m_title;
60 void XAwayService::setDescription( const QString& desc )
62 m_desc = desc;
65 QString XAwayService::description() const
67 return m_desc;
70 QString XAwayService::serviceId() const
72 return QString::fromUtf8( "cAwaySrv" );
75 void XAwayService::createRequest( QDomDocument& doc, QDomElement &e ) const
77 QDomElement eId = doc.createElement( "id" );
78 eId.appendChild( doc.createTextNode( "AwayStat" ) );
79 e.appendChild( eId );
81 QDomElement eTrans = doc.createElement( "trans" );
82 eTrans.appendChild( doc.createTextNode( "1" ) );
83 e.appendChild( eTrans );
85 QDomElement eSenderId = doc.createElement( "senderId" );
86 eSenderId.appendChild( doc.createTextNode( m_senderId ) );
87 e.appendChild( eSenderId );
91 void XAwayService::createResponse( QDomDocument& doc, QDomElement &e ) const
93 QDomElement eRoot = doc.createElement( "Root" );
95 eRoot.appendChild( doc.createElement( "CASXtraSetAwayMessage" ) );
97 QDomElement eSenderId = doc.createElement( "uin" );
98 eSenderId.appendChild( doc.createTextNode( m_senderId ) );
99 eRoot.appendChild( eSenderId );
101 QDomElement eIndex = doc.createElement( "index" );
102 eIndex.appendChild( doc.createTextNode( QString::number( m_iconIndex ) ) );
103 eRoot.appendChild( eIndex );
105 QDomElement eTitle = doc.createElement( "title" );
106 eTitle.appendChild( doc.createTextNode( m_title ) );
107 eRoot.appendChild( eTitle );
109 QDomElement eDesc = doc.createElement( "desc" );
110 eDesc.appendChild( doc.createTextNode( m_desc ) );
111 eRoot.appendChild( eDesc );
113 e.appendChild( eRoot );
116 void XAwayService::handleRequest( QDomElement& eRoot )
118 QDomNode childNode;
119 for ( childNode = eRoot.firstChild(); !childNode.isNull(); childNode = childNode.nextSibling() )
121 QDomElement e = childNode.toElement();
122 if( !e.isNull() )
124 if ( e.tagName() == "id" )
125 Q_ASSERT( e.text() == "AwayStat" );
126 // else if ( e.tagName() == "trans" )
127 else if ( e.tagName() == "senderId" )
128 m_senderId = e.text();
133 void XAwayService::handleResponse( QDomElement& eRoot )
135 QDomElement rootElement = eRoot.firstChild().toElement();
136 if ( !rootElement.isNull() && rootElement.tagName() == "Root" )
138 QDomNode childNode;
139 for ( childNode = rootElement.firstChild(); !childNode.isNull(); childNode = childNode.nextSibling() )
141 QDomElement e = childNode.toElement();
142 if( !e.isNull() )
144 if ( e.tagName() == "title" )
145 m_title = e.text();
146 else if ( e.tagName() == "desc" )
147 m_desc = e.text();
148 else if ( e.tagName() == "index" )
149 m_iconIndex = e.text().toInt();
150 else if ( e.tagName() == "uin" )
151 m_senderId = e.text();