33 #include <tdelocale.h>
34 #include <tdemessagebox.h>
36 #include "knotesnetsend.h"
38 #define CONNECT_TIMEOUT 10000
41 KNotesNetworkSender::KNotesNetworkSender( const TQString& hostname, int port )
42 : TDEBufferedSocket( hostname, TQString::number( port ) ),
43 m_note( 0 ), m_title( 0 ), m_sender( 0 ), m_index( 0 )
47 setTimeout( CONNECT_TIMEOUT );
51 TQObject::connect( this, TQ_SIGNAL(connected( const KResolverEntry& )),
52 TQ_SLOT(slotConnected( const KResolverEntry& )) );
53 TQObject::connect( this, TQ_SIGNAL(gotError( int )), TQ_SLOT(slotError( int )) );
54 TQObject::connect( this, TQ_SIGNAL(closed()), TQ_SLOT(slotClosed()) );
55 TQObject::connect( this, TQ_SIGNAL(readyWrite()), TQ_SLOT(slotReadyWrite()) );
58 void KNotesNetworkSender::setSenderId( const TQString& sender )
60 m_sender = sender.ascii();
63 void KNotesNetworkSender::setNote( const TQString& title, const TQString& text )
68 m_title = title.ascii();
69 m_note = text.ascii();
72 void KNotesNetworkSender::slotConnected( const KResolverEntry& )
74 if ( m_sender.isEmpty() )
75 m_note.prepend( m_title + "\n");
77 m_note.prepend( m_title + " (" + m_sender + ")\n" );
82 void KNotesNetworkSender::slotReadyWrite()
84 m_index += writeBlock( m_note.data() + m_index, m_note.length() - m_index );
87 if ( m_index == m_note.length() )
91 void KNotesNetworkSender::slotError( int err )
93 KMessageBox::sorry( 0, i18n( "Communication error: %1")
94 .arg( TQString(KNetwork::TDESocketBase::errorString( static_cast<TDESocketBase::SocketError >(err) )) )
99 void KNotesNetworkSender::slotClosed()
104 #include "knotesnetsend.moc"
|