Port things from MSN to WLM plugin:
[kdenetwork.git] / kopete / protocols / gadu / gadusession.cpp
blob6a42a552127e2044f705ba0ff270e18e268c65ea
1 // vim: set noet ts=4 sts=4 sw=4 :
2 // -*- Mode: c++-mode; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*-
3 //
4 // Copyright (C) 2003-2004 Grzegorz Jaskiewicz <gj at pointblue.com.pl>
5 // Copyright (C) 2002 Zack Rusin <zack@kde.org>
6 //
7 // gadusession.cpp
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 // 02110-1301, USA.
25 #include <ctime>
27 #include "gadusession.h"
29 #include <klocale.h>
30 #include <kdebug.h>
31 #include "kopetemessage.h"
33 #include <qsocketnotifier.h>
34 #include <qtextcodec.h>
35 #include <qdatetime.h>
36 //Added by qt3to4:
37 #include <QByteArray>
38 #include "gadurichtextformat.h"
40 #include <errno.h>
41 #include <string.h>
42 #include <netinet/in.h>
44 GaduSession::GaduSession( QObject* parent )
45 : QObject( parent ), session_( 0 ), searchSeqNr_( 0 )
47 textcodec = QTextCodec::codecForName( "CP1250" );
48 rtf = new GaduRichTextFormat;
51 GaduSession::~GaduSession()
53 logoff();
56 bool
57 GaduSession::isConnected() const
59 if ( session_ ) {
60 return ( session_->state & GG_STATE_CONNECTED );
62 return false;
65 int
66 GaduSession::status() const
68 if ( session_ ) {
69 kDebug(14100)<<"Status = " << session_->status <<", initial = "<< session_->initial_status;
70 return session_->status & ( ~GG_STATUS_FRIENDS_MASK );
72 return GG_STATUS_NOT_AVAIL;
75 void
76 GaduSession::login( struct gg_login_params* p )
78 if ( !isConnected() ) {
80 // turn on in case you have any problems, and you want
81 // to report it better. libgadu needs to be recompiled with debug enabled
82 // gg_debug_level=GG_DEBUG_MISC|GG_DEBUG_FUNCTION;
84 kDebug(14100) << "Login";
86 if ( !( session_ = gg_login( p ) ) ) {
87 destroySession();
88 kDebug( 14100 ) << "libgadu internal error ";
89 emit connectionFailed( GG_FAILURE_CONNECTING );
90 return;
93 createNotifiers( true );
94 enableNotifiers( session_->check );
95 searchSeqNr_=0;
99 void
100 GaduSession::destroyNotifiers()
102 disableNotifiers();
103 if ( read_ ) {
104 delete read_;
105 read_ = NULL;
107 if ( write_ ) {
108 delete write_;
109 write_ = NULL;
113 void
114 GaduSession::createNotifiers( bool connect )
116 if ( !session_ ){
117 return;
120 read_ = new QSocketNotifier( session_->fd, QSocketNotifier::Read, this );
121 read_->setEnabled( false );
123 write_ = new QSocketNotifier( session_->fd, QSocketNotifier::Write, this );
124 write_->setEnabled( false );
126 if ( connect ) {
127 QObject::connect( read_, SIGNAL( activated( int ) ), SLOT( checkDescriptor() ) );
128 QObject::connect( write_, SIGNAL( activated( int ) ), SLOT( checkDescriptor() ) );
132 void
133 GaduSession::enableNotifiers( int checkWhat )
135 if( (checkWhat & GG_CHECK_READ) && read_ ) {
136 read_->setEnabled( true );
138 if( (checkWhat & GG_CHECK_WRITE) && write_ ) {
139 write_->setEnabled( true );
143 void
144 GaduSession::disableNotifiers()
146 if ( read_ ) {
147 read_->setEnabled( false );
149 if ( write_ ) {
150 write_->setEnabled( false );
154 void
155 GaduSession::dccRequest( const unsigned int uin )
157 if ( session_ ) {
158 gg_dcc_request( session_, uin );
162 void
163 GaduSession::login( KGaduLoginParams* loginp )
165 QByteArray desc = textcodec->fromUnicode( loginp->statusDescr );
167 memset( &params_, 0, sizeof(params_) );
169 params_.status_descr = (char*)desc.data();
171 params_.uin = loginp->uin;
172 params_.password = loginp->password.data();
173 params_.status = loginp->status | ( loginp->forFriends ? GG_STATUS_FRIENDS_MASK : 0 );
174 params_.async = 1;
175 params_.tls = loginp->useTls;
176 params_ .server_addr = loginp->server;
177 params_.client_addr = loginp->client_addr;
178 params_.client_port = loginp->client_port;
180 kDebug(14100) << "LOGIN IP: " << loginp->client_addr;
182 if ( loginp->useTls ) {
183 params_.server_port = GG_HTTPS_PORT;
185 else {
186 if ( loginp->server ) {
187 params_.server_port = GG_DEFAULT_PORT;
191 kDebug(14100)<<"gadusession::login, server ( " << loginp->server << " ), tls(" << loginp->useTls << ") ";
192 login( &params_ );
196 void
197 GaduSession::destroySession()
199 if ( session_ ) {
200 destroyNotifiers();
201 gg_free_session( session_ );
202 session_ = 0;
206 void
207 GaduSession::logoff( Kopete::Account::DisconnectReason reason )
209 destroySession();
210 emit disconnect( reason );
214 GaduSession::notify( uin_t* userlist, int count )
216 if ( isConnected() ) {
217 return gg_notify( session_, userlist, count );
219 else {
220 emit error( i18n("Not Connected"), i18n("You are not connected to the server.") );
223 return 1;
227 GaduSession::addNotify( uin_t uin )
229 if ( isConnected() ) {
230 return gg_add_notify( session_, uin );
232 else {
233 emit error( i18n("Not Connected"), i18n("You are not connected to the server.") );
235 return 1;
239 GaduSession::removeNotify( uin_t uin )
241 if ( isConnected() ) {
242 gg_remove_notify( session_, uin );
244 else {
245 emit error( i18n("Not Connected"), i18n("You are not connected to the server.") );
248 return 1;
252 GaduSession::sendMessage( uin_t recipient, const Kopete::Message& msg, int msgClass )
254 QString sendMsg;
255 QByteArray cpMsg;
256 KGaduMessage* gadumessage;
258 if ( isConnected() ) {
259 gadumessage = rtf->convertToGaduMessage( msg );
260 if ( gadumessage ) {
261 const void* data = (const void*)gadumessage->rtf.data();
262 cpMsg = textcodec->fromUnicode( gadumessage->message );
263 int o;
264 o = gg_send_message_richtext( session_, msgClass, recipient, (const unsigned char *)cpMsg.data(), (const unsigned char*) data, gadumessage->rtf.size() );
265 gadumessage->rtf.resize(0);
266 delete gadumessage;
267 return o;
269 else {
270 sendMsg = msg.plainBody();
271 sendMsg.replace( QLatin1Char( '\n' ), QString::fromAscii( "\r\n" ) );
272 cpMsg = textcodec->fromUnicode( sendMsg );
274 return gg_send_message( session_, msgClass, recipient, (const unsigned char *)cpMsg.data() );
277 else {
278 emit error( i18n("Not Connected"), i18n("You are not connected to the server.") );
281 return 1;
285 GaduSession::changeStatus( int status, bool forFriends )
287 kDebug(14101)<<"## Changing to "<<status;
288 if ( isConnected() ) {
289 return gg_change_status( session_, status | ( forFriends ? GG_STATUS_FRIENDS_MASK : 0) );
291 else {
292 emit error( i18n("Not Connected"), i18n("You have to be connected to the server to change your status.") );
295 return 1;
299 GaduSession::changeStatusDescription( int status, const QString& descr, bool forFriends )
301 QByteArray ndescr;
303 ndescr= textcodec->fromUnicode(descr);
305 if ( isConnected() ) {
306 return gg_change_status_descr( session_,
307 status | ( forFriends ? GG_STATUS_FRIENDS_MASK : 0), ndescr.data() );
309 else {
310 emit error( i18n("Not Connected"), i18n("You have to be connected to the server to change your status.") );
313 return 1;
317 GaduSession::ping()
319 if ( isConnected() ) {
320 return gg_ping( session_ );
323 return 1;
326 void
327 GaduSession::pubDirSearchClose()
329 searchSeqNr_=0;
332 unsigned int
333 GaduSession::getPersonalInformation()
335 gg_pubdir50_t searchRequest;
336 unsigned int seqNr;
338 if ( isConnected() == false ) {
339 return 0;
342 searchRequest = gg_pubdir50_new( GG_PUBDIR50_READ );
343 if ( !searchRequest ) {
344 return 0;
347 seqNr = gg_pubdir50( session_, searchRequest );
348 gg_pubdir50_free( searchRequest );
350 return seqNr;
353 bool
354 GaduSession::publishPersonalInformation( ResLine& d )
356 gg_pubdir50_t r;
358 if ( !session_ ) {
359 return 0;
362 r = gg_pubdir50_new( GG_PUBDIR50_WRITE );
364 if ( d.firstname.length() )
365 gg_pubdir50_add( r, GG_PUBDIR50_FIRSTNAME,
366 (const char *)((const char*)textcodec->fromUnicode( d.firstname ) ) );
367 if ( d.surname.length() )
368 gg_pubdir50_add( r, GG_PUBDIR50_LASTNAME,
369 (const char *)((const char*)textcodec->fromUnicode( d.surname ) ) );
370 if ( d.nickname.length() )
371 gg_pubdir50_add( r, GG_PUBDIR50_NICKNAME,
372 (const char *)((const char*)textcodec->fromUnicode( d.nickname ) ) );
373 if ( d.age.length() )
374 gg_pubdir50_add( r, GG_PUBDIR50_BIRTHYEAR,
375 (const char *)((const char*)textcodec->fromUnicode( d.age ) ) );
376 if ( d.city.length() )
377 gg_pubdir50_add( r, GG_PUBDIR50_CITY,
378 (const char *)((const char*)textcodec->fromUnicode( d.city ) ) );
379 if ( d.meiden.length() )
380 gg_pubdir50_add( r, GG_PUBDIR50_FAMILYNAME,
381 (const char *)((const char*)textcodec->fromUnicode( d.meiden ) ) );
382 if ( d.orgin.length() )
383 gg_pubdir50_add( r, GG_PUBDIR50_FAMILYCITY,
384 (const char *)((const char*)textcodec->fromUnicode( d.orgin ) ) );
385 if ( d.gender.length() == 1 )
386 gg_pubdir50_add( r, GG_PUBDIR50_GENDER,
387 (const char *)((const char*)textcodec->fromUnicode( d.gender ) ) );
389 gg_pubdir50( session_, r );
391 gg_pubdir50_free( r );
393 return true;
396 unsigned int
397 GaduSession::pubDirSearch( ResLine& query, int ageFrom, int ageTo, bool onlyAlive )
399 QString bufYear;
400 unsigned int reqNr;
401 gg_pubdir50_t searchRequest;
403 if ( !session_ ) {
404 return 0;
407 searchRequest = gg_pubdir50_new( GG_PUBDIR50_SEARCH_REQUEST );
408 if ( !searchRequest ) {
409 return 0;
412 if ( query.uin == 0 ) {
413 if (query.firstname.length()) {
414 gg_pubdir50_add( searchRequest, GG_PUBDIR50_FIRSTNAME,
415 (const char*)textcodec->fromUnicode( query.firstname ) );
417 if ( query.surname.length() ) {
418 gg_pubdir50_add( searchRequest, GG_PUBDIR50_LASTNAME,
419 (const char*)textcodec->fromUnicode( query.surname ) );
421 if ( query.nickname.length() ) {
422 gg_pubdir50_add( searchRequest, GG_PUBDIR50_NICKNAME,
423 (const char*)textcodec->fromUnicode( query.nickname ) );
425 if ( query.city.length() ) {
426 gg_pubdir50_add( searchRequest, GG_PUBDIR50_CITY,
427 (const char*)textcodec->fromUnicode( query.city ) );
429 if ( ageFrom || ageTo ) {
430 QString yearFrom = QString::number( QDate::currentDate().year() - ageFrom );
431 QString yearTo = QString::number( QDate::currentDate().year() - ageTo );
433 if ( ageFrom && ageTo ) {
434 gg_pubdir50_add( searchRequest, GG_PUBDIR50_BIRTHYEAR,
435 (const char*)textcodec->fromUnicode( yearFrom + ' ' + yearTo ) );
437 if ( ageFrom ) {
438 gg_pubdir50_add( searchRequest, GG_PUBDIR50_BIRTHYEAR,
439 (const char*)textcodec->fromUnicode( yearFrom ) );
441 else {
442 gg_pubdir50_add( searchRequest, GG_PUBDIR50_BIRTHYEAR,
443 (const char*)textcodec->fromUnicode( yearTo ) );
447 if ( query.gender.length() == 1 ) {
448 gg_pubdir50_add( searchRequest, GG_PUBDIR50_GENDER,
449 (const char *)((const char*)textcodec->fromUnicode( query.gender ) ) );
452 if ( onlyAlive ) {
453 gg_pubdir50_add( searchRequest, GG_PUBDIR50_ACTIVE, GG_PUBDIR50_ACTIVE_TRUE );
456 // otherwise we are looking only for one fellow with this nice UIN
457 else{
458 gg_pubdir50_add( searchRequest, GG_PUBDIR50_UIN, QString::number( query.uin ).toAscii() );
461 gg_pubdir50_add( searchRequest, GG_PUBDIR50_START, QString::number( searchSeqNr_ ).toAscii() );
462 reqNr = gg_pubdir50( session_, searchRequest );
463 gg_pubdir50_free( searchRequest );
465 return reqNr;
468 void
469 GaduSession::sendResult( gg_pubdir50_t result )
471 int i, count, age;
472 ResLine resultLine;
473 SearchResult sres;
475 count = gg_pubdir50_count( result );
477 if ( !count ) {
478 kDebug(14100) << "there was nothing found in public directory for requested details";
481 for ( i = 0; i < count; i++ ) {
482 resultLine.uin = QString( gg_pubdir50_get( result, i, GG_PUBDIR50_UIN ) ).toInt();
483 resultLine.firstname = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_FIRSTNAME ) );
484 resultLine.surname = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_LASTNAME ) );
485 resultLine.nickname = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_NICKNAME ) );
486 resultLine.age = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_BIRTHYEAR ) );
487 resultLine.city = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_CITY ) );
488 QString stat = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_STATUS ) );
489 resultLine.orgin = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_FAMILYCITY ) );
490 resultLine.meiden = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_FAMILYNAME ) );
491 resultLine.gender = textcodec->toUnicode( gg_pubdir50_get( result, i, GG_PUBDIR50_GENDER ) );
493 resultLine.status = stat.toInt();
494 age = resultLine.age.toInt();
495 if ( age ) {
496 resultLine.age = QString::number( QDate::currentDate().year() - age );
498 else {
499 resultLine.age.truncate( 0 );
501 sres.append( resultLine );
502 kDebug(14100) << "found line "<< resultLine.uin << ' ' << resultLine.firstname;
505 searchSeqNr_ = gg_pubdir50_next( result );
506 emit pubDirSearchResult( sres, gg_pubdir50_seq( result ) );
509 void
510 GaduSession::requestContacts()
512 if ( !session_ || session_->state != GG_STATE_CONNECTED ) {
513 kDebug(14100) <<" you need to be connected to send ";
514 return;
517 if ( gg_userlist_request( session_, GG_USERLIST_GET, NULL ) == -1 ) {
518 kDebug(14100) <<" userlist export ERROR ";
519 return;
521 kDebug( 14100 ) << "Contacts list import..started ";
525 void
526 GaduSession::exportContactsOnServer( GaduContactsList* contactsList )
528 QByteArray plist;
530 if ( !session_ || session_->state != GG_STATE_CONNECTED ) {
531 kDebug( 14100 ) << "you need to connect to export Contacts list ";
532 return;
535 plist = textcodec->fromUnicode( contactsList->asString() );
536 kDebug(14100) <<"--------------------userlists\n" << plist;
537 kDebug(14100) << "----------------------------";
539 if ( gg_userlist_request( session_, GG_USERLIST_PUT, plist.data() ) == -1 ) {
540 kDebug( 14100 ) << "export contact list failed ";
541 return;
543 kDebug( 14100 ) << "Contacts list export..started ";
547 void
548 GaduSession::handleUserlist( gg_event* event )
550 QString ul;
551 switch( event->event.userlist.type ) {
552 case GG_USERLIST_GET_REPLY:
553 if ( event->event.userlist.reply ) {
554 ul = event->event.userlist.reply;
555 kDebug( 14100 ) << "Got Contacts list OK ";
557 else {
558 kDebug( 14100 ) << "Got Contacts list FAILED/EMPTY ";
559 // FIXME: send failed?
561 emit userListRecieved( ul );
562 break;
564 case GG_USERLIST_PUT_REPLY:
565 kDebug( 14100 ) << "Contacts list exported OK ";
566 emit userListExported();
567 break;
572 QString
573 GaduSession::stateDescription( int state )
575 switch( state ) {
576 case GG_STATE_IDLE:
577 return i18n( "idle" );
578 case GG_STATE_RESOLVING:
579 return i18n( "resolving host" );
580 case GG_STATE_CONNECTING:
581 return i18n( "connecting" );
582 case GG_STATE_READING_DATA:
583 return i18n( "reading data" );
584 case GG_STATE_ERROR:
585 return i18n( "error" );
586 case GG_STATE_CONNECTING_HUB:
587 return i18n( "connecting to hub" );
588 case GG_STATE_CONNECTING_GG:
589 return i18n( "connecting to server" );
590 case GG_STATE_READING_KEY:
591 return i18n( "retrieving key" );
592 case GG_STATE_READING_REPLY:
593 return i18n( "waiting for reply" );
594 case GG_STATE_CONNECTED:
595 return i18n( "connected" );
596 case GG_STATE_SENDING_QUERY:
597 return i18n( "sending query" );
598 case GG_STATE_READING_HEADER:
599 return i18n( "reading header" );
600 case GG_STATE_PARSING:
601 return i18n( "parsing data" );
602 case GG_STATE_DONE:
603 return i18n( "done" );
604 case GG_STATE_TLS_NEGOTIATION:
605 return i18n( "TLS connection negotiation" );
606 default:
607 return i18n( "unknown" );
610 QString
611 GaduSession::errorDescription( int err )
613 switch( err ){
614 case GG_ERROR_RESOLVING:
615 return i18n( "Resolving error." );
616 case GG_ERROR_CONNECTING:
617 return i18n( "Connecting error." );
618 case GG_ERROR_READING:
619 return i18n( "Reading error." );
620 case GG_ERROR_WRITING:
621 return i18n( "Writing error." );
622 default:
623 return i18n( "Unknown error number %1." , err );
627 QString
628 GaduSession::failureDescription( gg_failure_t f )
630 switch( f ) {
631 case GG_FAILURE_RESOLVING:
632 return i18n( "Unable to resolve server address. DNS failure." );
633 case GG_FAILURE_CONNECTING:
634 return i18n( "Unable to connect to server." );
635 case GG_FAILURE_INVALID:
636 return i18n( "Server sent incorrect data. Protocol error." );
637 case GG_FAILURE_READING:
638 return i18n( "Problem reading data from server." );
639 case GG_FAILURE_WRITING:
640 return i18n( "Problem sending data to server." );
641 case GG_FAILURE_PASSWORD:
642 return i18n( "Incorrect password." );
643 case GG_FAILURE_404:
644 return QString::fromAscii( "404." );
645 case GG_FAILURE_TLS:
646 return i18n( "Unable to connect over an encrypted channel.\nTry to turn off encryption support in the Gadu account settings, then reconnect." );
647 default:
648 return i18n( "Unknown error number %1." , f );
652 void
653 GaduSession::notify60( gg_event* event )
655 KGaduNotify* gn = NULL;
656 unsigned int n;
658 if ( event->event.notify60[0].uin ) {
659 gn = new KGaduNotify;
661 else {
662 return;
665 for( n=0 ; event->event.notify60[n].uin ; n++ ) {
666 gn->contact_id = event->event.notify60[n].uin;
667 gn->status = event->event.notify60[n].status;
668 gn->remote_ip.setAddress( ntohl( event->event.notify60[n].remote_ip ) );
669 gn->remote_port = event->event.notify60[n].remote_port;
670 if ( event->event.notify60[n].remote_ip && gn->remote_port > 10 ) {
671 gn->fileCap = true;
673 else {
674 gn->fileCap = false;
676 gn->version = event->event.notify60[n].version;
677 gn->image_size = event->event.notify60[n].image_size;
678 gn->description = textcodec->toUnicode( event->event.notify60[n].descr );
679 emit contactStatusChanged( gn );
681 delete gn;
684 void
685 GaduSession::checkDescriptor()
687 disableNotifiers();
689 struct gg_event* event;
690 // struct gg_dcc* dccSock;
691 KGaduMessage gaduMessage;
692 KGaduNotify gaduNotify;
694 if ( !( event = gg_watch_fd( session_ ) ) ) {
695 kDebug(14100)<<"Connection was broken for some reason";
696 destroyNotifiers();
697 logoff( Kopete::Account::ConnectionReset );
698 return;
701 // FD changed, recreate socket notifiers
702 if ( session_->state == GG_STATE_CONNECTING_HUB || session_->state == GG_STATE_CONNECTING_GG ) {
703 kDebug(14100)<<"recreating notifiers";
704 destroyNotifiers();
705 createNotifiers( true );
708 switch( event->type ) {
709 case GG_EVENT_MSG:
710 kDebug(14100) << "incoming message:class:" << event->event.msg.msgclass;
711 if ( event->event.msg.msgclass & GG_CLASS_CTCP ) {
712 kDebug( 14100 ) << "incoming ctcp ";
713 // TODO: DCC CONNECTION
714 emit incomingCtcp( event->event.msg.sender );
717 if ( (event->event.msg.msgclass & GG_CLASS_MSG) || (event->event.msg.msgclass & GG_CLASS_CHAT) ) {
718 gaduMessage.message =
719 textcodec->toUnicode((const char*)event->event.msg.message);
720 gaduMessage.sender_id = event->event.msg.sender;
721 gaduMessage.sendTime.setTime_t( event->event.msg.time );
722 gaduMessage.message = rtf->convertToHtml( gaduMessage.message, event->event.msg.formats_length, event->event.msg.formats );
723 emit messageReceived( &gaduMessage );
725 break;
726 case GG_EVENT_ACK:
727 emit ackReceived( event->event.ack.recipient );
728 break;
729 case GG_EVENT_STATUS:
730 gaduNotify.status = event->event.status.status;
731 gaduNotify.contact_id = event->event.status.uin;
732 if ( event->event.status.descr ) {
733 gaduNotify.description = textcodec->toUnicode( event->event.status.descr );
735 else {
736 gaduNotify.description.clear();
738 gaduNotify.remote_port = 0;
739 gaduNotify.version = 0;
740 gaduNotify.image_size = 0;
741 gaduNotify.time = 0;
742 gaduNotify.fileCap = false;
744 emit contactStatusChanged( &gaduNotify );
745 break;
746 case GG_EVENT_STATUS60:
747 gaduNotify.status = event->event.status60.status;
748 gaduNotify.contact_id = event->event.status60.uin;
749 if ( event->event.status60.descr ) {
750 gaduNotify.description = textcodec->toUnicode( event->event.status60.descr );
752 else {
753 gaduNotify.description.clear();
755 gaduNotify.remote_ip.setAddress( ntohl( event->event.status60.remote_ip ) );
756 gaduNotify.remote_port = event->event.status60.remote_port;
757 gaduNotify.version = event->event.status60.version;
758 gaduNotify.image_size = event->event.status60.image_size;
759 gaduNotify.time = event->event.status60.time;
760 if ( event->event.status60.remote_ip && gaduNotify.remote_port > 10 ) {
761 gaduNotify.fileCap = true;
763 else {
764 gaduNotify.fileCap = false;
767 emit contactStatusChanged( &gaduNotify );
768 break;
769 case GG_EVENT_NOTIFY60:
770 notify60( event );
771 break;
772 case GG_EVENT_CONN_SUCCESS:
773 kDebug(14100) << "success server: " << session_->server_addr;
774 emit connectionSucceed();
775 break;
776 case GG_EVENT_CONN_FAILED:
777 kDebug(14100) << "failed server: " << session_->server_addr;
778 destroySession();
779 kDebug(14100) << "emit connection failed(" << event->event.failure << ") signal";
780 emit connectionFailed( (gg_failure_t)event->event.failure );
781 break;
782 case GG_EVENT_DISCONNECT:
783 kDebug(14100)<<"event Disconnected";
784 // it should be called either when we requested disconnect, or when other client connects with our UID
785 logoff( Kopete::Account::Manual );
786 break;
787 case GG_EVENT_PONG:
788 emit pong();
789 break;
790 case GG_EVENT_NONE:
791 break;
792 case GG_EVENT_PUBDIR50_SEARCH_REPLY:
793 case GG_EVENT_PUBDIR50_WRITE:
794 case GG_EVENT_PUBDIR50_READ:
795 sendResult( event->event.pubdir50 );
796 break;
797 case GG_EVENT_USERLIST:
798 handleUserlist( event );
799 break;
800 default:
801 kDebug(14100)<<"Unprocessed GaduGadu Event = "<<event->type;
802 break;
805 if ( event ) {
806 gg_free_event( event );
809 if ( session_ ) {
810 enableNotifiers( session_->check );
814 #include "gadusession.moc"