00001
00002 #include "ignytegrabber.h"
00003
00004 IgnyteGrabber::IgnyteGrabber(QString zip, QString radius, QApplication *callingApp)
00005 {
00006 app = callingApp;
00007
00008 QString fields ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
00009 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" "
00010 "xmlns:tns=\"http://www.ignyte.com/whatsshowing\" xmlns:xs=\"http://www.w3.org"
00011 "/2001/XMLSchema\">\n"
00012 "<soap:Body>\n"
00013 "<tns:GetTheatersAndMovies>\n"
00014 "<tns:zipCode>" + zip + "</tns:zipCode>\n"
00015 "<tns:radius>" + radius + "</tns:radius>\n"
00016 "</tns:GetTheatersAndMovies>\n"
00017 "</soap:Body>\n"
00018 "</soap:Envelope>\n");
00019 QString server("ignyte.com");
00020 QString path("/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx");
00021 QString soapAction("http://www.ignyte.com/whatsshowing/GetTheatersAndMovies");
00022 ms.doSoapRequest(server, path, soapAction, fields);
00023
00024 waitForSoap = new QTimer(this);
00025 connect(waitForSoap, SIGNAL(timeout()), this, SLOT(checkHttp()));
00026 waitForSoap->start(0, FALSE);
00027 }
00028
00029 void IgnyteGrabber::checkHttp()
00030 {
00031 if (ms.isDone())
00032 {
00033 if (ms.hasError())
00034 {
00035 cerr << "Data Source Error" << endl << flush;
00036 }
00037 else
00038 {
00039 outputData(ms.getResponseData().data());
00040 }
00041 waitForSoap->stop();
00042 app->exit();
00043 }
00044 }
00045
00046 void IgnyteGrabber::outputData(QString data)
00047 {
00048 int i = data.find("<GetTheatersAndMoviesResult>");
00049 data = data.mid(i + 28);
00050 int x = data.find("</GetTheatersAndMoviesResult>");
00051 data = data.left(x);
00052 data = data.remove('\r');
00053 data = data.remove('\n');
00054 data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><MovieTimes>" + data + "</MovieTimes>";
00055 cout << data;
00056 }