You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdevelop/languages/cpp/app_templates/tdeioslave/slave.cpp

89 lines
2.2 KiB

#include <tqcstring.h>
#include <tqsocket.h>
#include <tqdatetime.h>
#include <tqbitarray.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <tdeapplication.h>
#include <kdebug.h>
#include <tdemessagebox.h>
#include <kinstance.h>
#include <tdeglobal.h>
#include <kstandarddirs.h>
#include <tdelocale.h>
#include <kurl.h>
#include <ksock.h>
#include "%{APPNAMELC}.h"
using namespace TDEIO;
12 years ago
tdeio_%{APPNAMELC}Protocol::tdeio_%{APPNAMELC}Protocol(const TQCString &pool_socket, const TQCString &app_socket)
: SlaveBase("tdeio_%{APPNAMELC}", pool_socket, app_socket)
{
12 years ago
kdDebug() << "tdeio_%{APPNAMELC}Protocol::tdeio_%{APPNAMELC}Protocol()" << endl;
}
12 years ago
tdeio_%{APPNAMELC}Protocol::~tdeio_%{APPNAMELC}Protocol()
{
12 years ago
kdDebug() << "tdeio_%{APPNAMELC}Protocol::~tdeio_%{APPNAMELC}Protocol()" << endl;
}
12 years ago
void tdeio_%{APPNAMELC}Protocol::get(const KURL& url )
{
12 years ago
kdDebug() << "tdeio_%{APPNAMELC}::get(const KURL& url)" << endl ;
kdDebug() << "Seconds: " << url.query() << endl;
TQString remoteServer = url.host();
int remotePort = url.port();
kdDebug() << "myURL: " << url.prettyURL() << endl;
infoMessage(i18n("Looking for %1...").arg( remoteServer ) );
// Send the mimeType as soon as it is known
mimeType("text/plain");
// Send the data
12 years ago
TQString theData = "This is a test of tdeio_%{APPNAMELC}";
data(TQCString(theData.local8Bit()));
data(TQByteArray()); // empty array means we're done sending the data
finished();
}
12 years ago
void tdeio_%{APPNAMELC}Protocol::mimetype(const KURL & /*url*/)
{
mimeType("text/plain");
finished();
}
extern "C"
{
int kdemain(int argc, char **argv)
{
12 years ago
TDEInstance instance( "tdeio_%{APPNAMELC}" );
12 years ago
kdDebug(7101) << "*** Starting tdeio_%{APPNAMELC} " << endl;
if (argc != 4) {
12 years ago
kdDebug(7101) << "Usage: tdeio_%{APPNAMELC} protocol domain-socket1 domain-socket2" << endl;
exit(-1);
}
12 years ago
tdeio_%{APPNAMELC}Protocol slave(argv[2], argv[3]);
slave.dispatchLoop();
12 years ago
kdDebug(7101) << "*** tdeio_%{APPNAMELC} Done" << endl;
return 0;
}
}