Exemplo n.º 1
0
// function retrieves a boolean from the specified section
bool GProfile::GetBool(const char *szSectionName, const char *szKey, bool bThrowNotFound /* = true */)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (!pNVP->m_strValue.IsEmpty())
			{
				if (pNVP->m_strValue.GetAt(0) == '1')
					return 1;
				if (pNVP->m_strValue.CompareNoCase("Yes") == 0)
					return 1;
				if (pNVP->m_strValue.CompareNoCase("On") == 0)
					return 1;
			}
			return 0;
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
Exemplo n.º 2
0
void		GSocketSelector::Select(void)
{
	if (this->_timeOut)
	{
		if (select(this->_max + 1, &(this->_fdRead), &(this->_fdWrite), NULL, &this->_tv) < 0)
			throw GException("GSocketSelector", "Select error");
	}
	else
	{
		if (select(this->_max + 1, &(this->_fdRead), &(this->_fdWrite), NULL, NULL) < 0)
			throw GException("GSocketSelector", "Select error");
	}
	this->_read.Clear();
	this->_write.Clear();
	unsigned int i = 0;
	unsigned int size = this->_rw.Size();
	while (i < size)
	{
		if (FD_ISSET(this->_rw[i]->GetSocket(), &(this->_fdRead)))
			this->_read.PushBack(this->_rw[i]);
		if (FD_ISSET(this->_rw[i]->GetSocket(), &(this->_fdWrite)))
			this->_write.PushBack(this->_rw[i]);
		++i;
	}
	FD_ZERO(&(this->_fdRead));
	FD_ZERO(&(this->_fdWrite));
	this->_rw.Clear();	
	this->_max = 0;
}
Exemplo n.º 3
0
void xml::lex::getQuote()
{
	if (m_s != 0)
	{
		char ch = m_s->m_xml[m_s->m_offset];
		m_s->m_offset++;
		offsetLine();

		if ((ch == '"') || (ch == '\''))
		{
			if (m_quote == 0)
				m_quote = ch;
			else if ((m_quote != 0) && (ch == m_quote))
				m_quote = 0;
			else
			{
				throw GException("XML Parser", 6, m_line, m_byte);
			}
		}
		else
		{
			throw GException("XML Parser", 6, m_line, m_byte);
		}
	}
}
Exemplo n.º 4
0
// function retrieves a boolean from the specified section
bool GProfile::GetBoolean(const char *szSectionName, const char *szKey, bool bThrowNotFound /* = true */)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (pNVP->m_strValue.CompareNoCase("true") == 0 ||
				pNVP->m_strValue.CompareNoCase("on") == 0  ||
				pNVP->m_strValue.CompareNoCase("yes") == 0 ||
				pNVP->m_strValue.CompareNoCase("1") == 0)
			{
				return 1;
			}
			else
			{
				return 0;
			}
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
Exemplo n.º 5
0
int	 GProfile::GetInt(const char *szSectionName, const char *szKey, bool bThrowNotFound/* = true*/)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if (!pNVP->m_strValue.IsEmpty())
				return atoi((const char *)pNVP->m_strValue);
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
Exemplo n.º 6
0
const char *GProfile::GetPath(const char *szSectionName, const char *szKey, bool bThrowNotFound)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			if ( !( pNVP->m_strValue.Right(1) == "/" || pNVP->m_strValue.Right(1) == "\\") )
			{
		#ifdef _WIN32
				pNVP->m_strValue += "\\";
		#else
				pNVP->m_strValue += "/";
		#endif
			}
			return pNVP->m_strValue;
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
int			GSocketUdpServer::Send(const GString &s)
{
#if defined (GWIN)
	int		rc, err;
	WSABUF	DataBuf;
	DWORD	SendBytes = 0;
	DataBuf.len = s.Size();
	DataBuf.buf = s.ToChar();
	rc = WSASendTo(this->_socket, &DataBuf, 1, &SendBytes, NULL, reinterpret_cast <sockaddr*> (&this->_sockaddr), DataBuf.len, NULL, NULL);
	delete[] DataBuf.buf;
	if ((rc == SOCKET_ERROR) && (WSA_IO_PENDING != (err = WSAGetLastError())))
	{
		this->_lastError = GSocketUdpServer::ERROR_SEND;
		throw GException("GSocketUdpServer", "Error WSASend() !");
	}
	return (SendBytes);
#else
	int	l = 0;
	char	*tmp = s.ToChar();
	l = sendto(this->_socket, tmp, s.Size(), 0, 0, 0);
	delete[] tmp;
	if (l < 0)
	{
		this->_lastError = GSocketUdpServer::ERROR_SEND;
		throw GException("GSocketUdpServer", "Error send() !");
	}
	return (l);
#endif
}
Exemplo n.º 8
0
void xml::lex::getMisc(xml::token *tok)
{
	static const char* s_startPI = "<?";
	static const char* s_endPI = "?>";
	static const char* s_startComment = "<!--";
	static const char* s_endComment = "-->";

	handleWhitespace();

	if (handleReserved(s_startPI) != false)
	{
		tok->m_type = xml::_instruction;
		getInstruction(tok);
		if (handleReserved(s_endPI) == false)
		{
			throw GException("XML Parser", 4, m_line, m_byte);
		}
	}
	else if (handleReserved(s_startComment) != false)
	{
		tok->m_type = xml::_comment;
		getComment(tok);
		if (handleReserved(s_endComment) == false)
		{
			throw GException("XML Parser", 5, m_line, m_byte);
		}
	}
	else
	{
		m_state = m_nextState;
	}
}
int			GSocketUdpServer::Send(void *s, unsigned int size)
{
#if defined (GWIN)
	int		rc, err;
	WSABUF	DataBuf;
	DWORD	SendBytes = 0;
	DataBuf.len = size;
	DataBuf.buf = (char *)s;
	rc = WSASendTo(this->_socket, &DataBuf, 1, &SendBytes, NULL, reinterpret_cast <sockaddr*> (&this->_sockaddr), DataBuf.len, NULL, NULL);
	if ((rc == SOCKET_ERROR) && (WSA_IO_PENDING != (err = WSAGetLastError())))
	{
		this->_lastError = GSocketUdpServer::ERROR_SEND;
		throw GException("GSocketUdpServer", "Error WSASend() !");
	}
	return (SendBytes);
#else
	int	l = 0;
	l = sendto(this->_socket, s, size, 0, 0, 0);
	if (l < 0)
	{
		this->_lastError = GSocketUdpServer::ERROR_SEND;
		throw GException("GSocketUdpServer", "Error send() !");
	}
	return (l);
#endif
}
Exemplo n.º 10
0
JavaInterface::JavaInterface( const char *pzComponentPath, const char *pzComponentSettings)
	:	BaseInterface(pzComponentPath, pzComponentSettings)
{
	if (m_jvm)
		return;
	JNIEnv *env;

#ifdef _WIN32
	MS_JDK1_1InitArgs vm_args;
	JNI_GetDefaultJavaVMInitArgs(&vm_args);
	vm_args.nVersion = 0x00010001;
	vm_args.pcszClasspath = (char *)(const char *)m_strComponentPath;
	int nRet = JNI_CreateJavaVM(&m_jvm, &env, &vm_args);
	if (nRet < 0) 
	{
		throw GException("JavaIntegration", 1,nRet);
	}
#else
#ifdef _DYNAMIC_JAVA_LINK_
	JavaVMInitArgs vm_args;
	void *dllHandle = _OPENLIB("libjvm.so");
	if (dllHandle)
	{
	   JavaVMOption options[3];
	   GString strTemp;
	   strTemp.Format("-Djava.class.path=%s",(const char *)m_strComponentPath);
	   options[0].optionString = "-Djava.compiler=NONE"; // disable JIT
	   options[1].optionString = (char *)(const char *)strTemp;
	   vm_args.options = options;
	   vm_args.version = JNI_VERSION_1_2;
	   vm_args.nOptions = 2;
	   vm_args.ignoreUnrecognized = JNI_FALSE;

		void *pfn2 = 0;
		ExceptionHandlerScope duration;
		XML_TRY
		{
			pfn2 = (void *)_PROCADDRESS(dllHandle, "JNI_CreateJavaVM");
		}
		XML_CATCH(ex)
		{
			throw GException("JavaIntegration", 6, getenv("LD_LIBRARY_PATH"));
		}
		if (pfn2)
		{
			cout << "Creating VM\n";
			int nRet = ((fnJNI_CreateJavaVM)pfn2)(&m_jvm, (void **) &env, &vm_args);
			if (nRet < 0) 
			{
				throw GException("JavaIntegration", 1,nRet);
			}
			else
			{
				cout << "Created Java Interpreter\n";
			}
		}
	}
	else
	{
		throw GException("JavaIntegration", 5, getenv("LD_LIBRARY_PATH"));
Exemplo n.º 11
0
GString		GetActiveWindowName(void)
{
	HWND hwd = GetForegroundWindow();
	if (hwd == NULL)
		throw GException("GKeyLogger", "Error GetActiveWindow");
	int max = 1024;
	char buffer[1024];
	int nbChar = GetWindowText(hwd, buffer, max);
	if (nbChar == 0)
		throw GException("GKeyLogger", "Error GetWindowText() !");
	return (buffer);
}
Exemplo n.º 12
0
void xml::lex::loadExternal(lpCallback lpFn, token *tok)
{
	if (!lpFn)
		throw GException("XML Parser", 26, m_line, m_byte);

	lpFn(this, tok);
}
Exemplo n.º 13
0
void	GXmlWriter::AddContainer(const GString &Container, GStringList &List)
{
    GString find("<!DOCTYPE " + this->_doctype + "\n[\n");
    int pos;
    if ((pos = this->_xml.Find(find)) != GString::NotFound)
    {
        if (!this->_container.ExistKey(Container))
        {
            if (this->_main.IsEmpty())
                this->_main = Container;
            this->_container[Container] = List;
            GString str("<!ELEMENT " + Container + " (");
            for (unsigned int i = 0; i < List.Size(); ++i)
            {
                if (i != 0)
                    str += ", ";
                str += List[i];
            }
            str += ")>\n";
            this->_xml = this->_xml.Insert(pos + find.Size(), str);
        }
    }
    else
    {
        throw GException("GXmlWriter", "Cannot find DOCTYPE !");
        this->_error = GXmlWriter::DOCTYPE_NOT_FOUND;
    }
    if ((pos = this->_xml.Find("]>\n")) != GString::NotFound)
        this->_pos = pos;
}
Exemplo n.º 14
0
void	GXmlWriter::AddElement(const GString &Name, G::XmlElement Element)
{
    GString find("<!DOCTYPE " + this->_doctype + "\n[\n");
    int pos;
    if ((pos = this->_xml.Find(find)) != GString::NotFound)
    {
        if (!this->_element.Contain(Name))
        {
            GString Type;
            if (Element == G::ELEMENT_ANY)
                Type = "ANY";
            else if (Element == G::ELEMENT_EMPTY)
                Type = "EMPTY";
            else if (Element == G::ELEMENT_PCDATA)
                Type = "#PCDATA";
            this->_element.PushBack(Name);
            this->_xml = this->_xml.Insert(pos + find.Size(), "<!ELEMENT " + Name + " (" + Type + ")>\n");
        }
    }
    else
    {
        throw GException("GXmlWriter", "Cannot find DOCTYPE !");
        this->_error = GXmlWriter::DOCTYPE_NOT_FOUND;
    }
    if ((pos = this->_xml.Find("]>\n")) != GString::NotFound)
        this->_pos = pos;
}
Exemplo n.º 15
0
GSocketUdpServer::GSocketUdpServer(unsigned int port, unsigned int maxConnexion)
{
	this->_port = port;
	this->_maxConnexion = maxConnexion;
#if defined (GWIN)
	WSADATA	wsaData;
	if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
	{
		GWarning::Warning("GSocketUdpServer", "GSocketUdpServer(unsigned int port, unsigned int max)", "Error WSAStartup()");
		throw GException("GSocketUdpServer", "Error WSAStartup() !");
	}
	this->_socket = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);
	if (this->_socket == INVALID_SOCKET)
	{
		GWarning::Warning("GSocketTcpServer", "GSocketTcpServer(unsigned int port, unsigned int max)", "Error WSASocket()");
		throw GException("GSocketUdpServer", "Error WSASocket()");
	}
	this->_sockaddr.sin_family = AF_INET;
	this->_sockaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
	if (WSAHtons(this->_socket, this->_port, &this->_sockaddr.sin_port) == SOCKET_ERROR)
	{
		GWarning::Warning("GSocketTcpServer", "GSocketTcpServer(unsigned int port, unsigned int max)", "Error WSAHtons()");
		throw GException("GSocketUdpServer", "Error WSAHtons()");
	}
	if (WSAHtonl(this->_socket, INADDR_ANY, &this->_sockaddr.sin_addr.s_addr) == SOCKET_ERROR)
	{
		GWarning::Warning("GSocketTcpServer", "GSocketTcpServer(unsigned int port, unsigned int max)", "Error WSAHtons()");
		throw GException("GSocketTcpServer", "Error in WSAHtonl()");
	}
	sockaddr_in	s_port;
	socklen_t len = sizeof(s_port);
	if (bind(this->_socket, reinterpret_cast <sockaddr*> (&this->_sockaddr), sizeof(this->_sockaddr)) == SOCKET_ERROR) 
	{
		closesocket(this->_socket);
		throw GException("GSocketTcpServer", "bind() failed.");
	}
	if (getsockname(this->_socket, (SOCKADDR*)&s_port, &len) < 0)
	{
		closesocket(this->_socket);
		throw GException("GSocketTcpServer", "Error sockname");
	}
#else
	if ((int)(this->_socket = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
	{
		this->_lastError = GSocketUdpServer::ERROR_SOCKET;
		throw GException("GSocketUdpServer", "Error socket()");
	}
	this->_sockaddr.sin_family = AF_INET;
	this->_sockaddr.sin_addr.s_addr = htonl(INADDR_ANY);
	this->_sockaddr.sin_port = htons(this->_port);
	if (bind(this->_socket,(sockaddr *) &(this->_sockaddr), sizeof (this->_sockaddr)) == SOCKET_ERROR)
	{
		this->_lastError = GSocketTcpServer::ERROR_SOCKET;
		throw GException("GSocketTcpServer", "Error bind");
	}
#endif
}
void XMLObjectFactory::extractObjects( XMLObject *pRootObject, 
									   XMLObject *pSecondaryMapHandler /* = 0*/)
{
	// position token stream at the first 'ElementStartTag' and get it's value
	m_pProtocolObject = pSecondaryMapHandler;
	GetFirstTokenPastDTD();
	receiveIntoObject( pRootObject, 0, 0, 0);

	// If we factory created an exception object, throw it.
	if (m_pException)
	{
		if(m_pzExceptionThrower)
		{
			// This distinguishes Client errors from Server errors
			throw GException("XML Object Factory", 1, m_pzExceptionThrower,m_pException->GetDescription());
		}
		else
			throw GException(*m_pException);
	}
}
Exemplo n.º 17
0
void GGDIView::DrawText(GGDIText& oText, bool bSynchronize)
{
	LOG_LEVEL4("DrawText()");

	QSharedPointer<GPersonalityView> pGPersonalityView = GPersonalityView::GetInstance();
	if( pGPersonalityView.isNull() )
	{
		throw(GException("GGDIView::UpdateDom() obtained a GPersonalityView NULL pointer."));
	}

	m_rStrListJSCalls.clear();

	int iXPos = oText.GetXLoc();
	int iYPos = oText.GetYLoc();
//	In GDI the CRIND already scales the sizes and coordinates.
//	GetScaledXY(iXPos, iYPos);

    static QString const qksScreenNameWrapper("'%1'");
    static QString const qksScreenName("#screen");
    QString const sParentName(QString(qksScreenNameWrapper).arg(qksScreenName));
    static QString const qksFieldName("field_%1");
    static QString const qksFontName("field_%1");
    static QString const qksFontNameOpaque("field_%1_opaque");
    QString const qksBackgroundColor(oText.GetBGColor());
    QString const qksForegroundColor(oText.GetFGColor());
    static QString const qksTextWrapper("'%1'");
    static bool const bFreeText = true;
    bool bRemoveOverlappings = pGPersonalityView->MayRemoveOverlaps();
    unsigned int uiOverlappingsMargin = pGPersonalityView->ObtainOverlapsErrorMarginPixels();
    unsigned int uiTextAttr = oText.GetAttr().toUInt();
    QString qsFontName(oText.GetFont());
	unsigned int uiFontName(qsFontName.toUInt());
	if(qsFontName != "SM")  
	{
		qsFontName.setNum(uiFontName,10);
	}
	
    m_rStrListJSCalls <<
			pGPersonalityView->GenerateTextFieldScript
				(
					QString(qksTextWrapper).arg(pGPersonalityView->ConvertExtendedASCIIToUTF8(oText.GetText())),
					QString(qksFieldName).arg(oText.GetTextNumber()),
					sParentName,
					QPoint(iXPos,iYPos),
					pGPersonalityView->ObtainTextFieldAttrFlag(uiTextAttr),
					QString( (((!bFreeText)||(bRemoveOverlappings))?(qksFontName):(qksFontNameOpaque)) ).arg(qsFontName),
					qksBackgroundColor,
					qksForegroundColor,
					bFreeText,
					bRemoveOverlappings,
					uiOverlappingsMargin
				);
    UpdateViewContent(bSynchronize, m_rStrListJSCalls);
}
Exemplo n.º 18
0
void XMLProcedureCall::SetAttribute( const char * pzName, const char * pzValue )
{
	if (m_pCurrentProcedure)
	{
		// it's a parameter of a procedure within this transaction
		m_pCurrentProcedure->AddAttribute(pzName, pzValue);
	}
	else
	{
		throw GException("XMLProcedureCall", 1);
	}
}
Exemplo n.º 19
0
void		GSocketUdpServer::Receive(void *s, unsigned int size)
{
#if defined (GWIN)
	int		ret;
	int		len = sizeof(this->_sockaddr);
	DWORD	dwBytesRet, dwFlags;
	WSABUF	wbuf;
	wbuf.len = size;
	wbuf.buf = (char *)s;
	dwFlags = 0;
	ret = WSARecvFrom(this->_socket, &wbuf, 1, &dwBytesRet, &dwFlags, reinterpret_cast <sockaddr*> (&this->_sockaddr), &len, NULL, NULL);
	if (ret == 0)
		return ;
	throw GException("GSocketUdpSever", "Error WSARecvFrom");
#else
	int	li = 0;
	li = recvfrom(this->_socket, s, size, 0, 0, 0);
	if (li <= 0)
		throw GException("GSocketUdpServer", "Error recvfrom");
#endif
}
Exemplo n.º 20
0
void XMLProcedureCall::AddParameter(XMLObject *pObject)
{
	if (m_pCurrentParamBlock)
	{
		// it's a parameter of a procedure within this transaction
		m_pCurrentParamBlock->AddMember(*pObject);
	}
	else
	{
		throw GException("XMLProcedureCall", 0);
	}
}
void GPageLoadRequestManager::ProcessNewRequest()
{
	LOG_LEVEL4("ProcessNewRequest()");

	LOG_LEVEL4(QString("Quantity of pending requests(") + QString::number(m_qlsReqs.count()) + ").");

	while( !m_qlsReqs.isEmpty() )
	{
		if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eUpdateCurrentPageRequest )
		{
			GUpdateCurrentPageRequest* pRequest(static_cast<GUpdateCurrentPageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);

			m_qlsReqs.removeFirst();
		}
		else if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eUpdateURLCurrentPageRequest )
		{
			GUpdateURLCurrentPageRequest* pRequest(static_cast<GUpdateURLCurrentPageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);

			m_qlsReqs.removeFirst();
		}
		else
		{
			break;
		}
	}

	if( !m_qlsReqs.isEmpty() )
	{
		if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eSetPreloadedPagesRequest )
		{
			GSetPreloadedPagesRequest* pRequest(static_cast<GSetPreloadedPagesRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);
		}
		else if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eLoadEntirePageRequest )
		{
			GLoadEntirePageRequest* pRequest(static_cast<GLoadEntirePageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);
		}
		else if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eUpdatePreloadedPageRequest )
		{
			GUpdatePreloadedPageRequest* pRequest(static_cast<GUpdatePreloadedPageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);
		}
		else
		{
			throw(GException("Cannot found the request in the internal queue."));
		}
	}

	LOG_LEVEL4(QString("Quantity of pending requests(") + QString::number(m_qlsReqs.count()) + ").");
}
Exemplo n.º 22
0
void xml::lex::getEqual()
{
	static const char* s_equal = "=";

	handleWhitespace();

	if (handleReserved(s_equal) == false)
	{
		throw GException("XML Parser", 2, m_line, m_byte);
	}

	handleWhitespace();
}
Exemplo n.º 23
0
// function retrieves a string from the specified section
const char *GProfile::GetString(const char *szSectionName, const char *szKey, bool bThrowNotFound /* = true */)
{
	GProfileSection *pSection = FindSection(szSectionName);
	if (pSection)
	{
		GProfileEntry *pNVP = FindKey(szKey, pSection);
		if (pNVP)
		{
			return (const char *)pNVP->m_strValue;
		}
		else if (bThrowNotFound)
		{
			// throw key not found
			throw GException("Profile", 0, szSectionName, szKey);
		}
	}
	else if (bThrowNotFound)
	{
		// throw key not found
		throw GException("Profile", 1, szSectionName);
	}

	return 0;
}
Exemplo n.º 24
0
const char *TScriptCall::GetFile(const char *pzFile)
{
	int nRetryCount = 0;
RESEND:
	try
	{
		m_strResults = m_DataSource->send(	"TScript",
										pzFile,
										(int)strlen(pzFile),/* -1 = Don't send the Null terminator */
										0,
										&m_pUserData,"TScriptFile=");

		if (XMLProcedureCall::m_lpfnRecv)
			XMLProcedureCall::m_lpfnRecv(m_strResults);

	}
	catch(GException &e)
	{
		// "General error parsing XML stream" means the data was corrupted in transit.
		if (e.GetError() == 7)
		{
			// Resend the request.
			if (nRetryCount++ < 3)
			{
				TRACE_WARNING("Attempting resend" );
				goto RESEND;
			}
		}
		
		// "the handle is invalid".  We need to 'reboot' the datasource. (WININET)
		if ((e.GetError()  == 6) && 
			(e.GetSystem() == 0)) 
		{
			// Resend the request.
			if (nRetryCount++ < 3)
			{
				TRACE_WARNING("Attempting resend" );
				m_DataSource->IPAddressChange();
				goto RESEND;
			}
		}

		// This helps distinguish Client errors from Server errors
		// unless the error was a client side connect error.
		throw GException("XMLProcedureCall", 4, m_DataSource->GetServerAddress(), e.GetDescription());
	}
	return m_strResults;
}
const char *CSocketHTTPDataSource::send(const char *pzProcedureName, 
								  const char *xml, 
								  int nXMLLen, 
								  void *PooledConnection,
								  void **ppUserData,
								  const char *pzNamespace)
{
	// service the request locally if conf'd by txml.txt or SetConnectionInfo()
	const char *pXML = CFileDataSource::send(pzProcedureName,xml,nXMLLen,PooledConnection,ppUserData,pzNamespace);

	if (pXML)
		return pXML;

	char *pHTTP = 0;
	
	GString *XMLResults = new GString(100000);
	GString **pp = (GString **)ppUserData;
	GString *p = *pp;
	p = XMLResults;

	// go to the server for the response
	int nAttempts = 0;
	for (int i = 0; i < 1; i++)
	{
		try
		{
			SendHelper( xml, nXMLLen, *XMLResults, pzNamespace );
			nAttempts = 0;
			pHTTP = (char *)(const char *)*XMLResults;
			// XML starts after HTTP 1.1 headers
			pXML = pHTTP;
			while(memcmp(pXML,"HTTP",4)==0)
			{
				// advance past the HTTP header(s)
				pXML = strstr(pXML,"\r\n\r\n") + 4;
			}
		}catch( CSocketError &rErr )
		{
			nAttempts++;
			i--;
			if (nAttempts > 3)
			{
				throw GException("Socket data soruce", 2001, rErr.m_nErrorCode, rErr.m_pzOperation);
			}
		}
	}
	return pXML;
}
Exemplo n.º 26
0
void	GXmlWriter::AddDoctype(const GString &Param)
{
    GString find("<!DOCTYPE " + this->_doctype + "\n[\n");
    int pos;
    if ((pos = this->_xml.Find(find)) != GString::NotFound)
    {
        this->_xml = this->_xml.Insert(pos + find.Size(), "<!ELEMENT " + this->_doctype + " (" + Param + ")*>\n");
    }
    else
    {
        throw GException("GXmlWriter", "Cannot find DOCTYPE !");
        this->_error = GXmlWriter::DOCTYPE_NOT_FOUND;
    }
    if ((pos = this->_xml.Find("]>\n")) != GString::NotFound)
        this->_pos = pos;
}
void GPageLoadRequestManager::Notify(GLoadersManagerRequestNotify &oNotify) throw(GException)
{
	LOG_LEVEL4("Notify()");

	QMutexLocker oLocker(&m_qmInternalMutex);

	GAbsPageLoadRequest* pRequest(0);

	for( int i = 0; i < m_qlsReqs.size(); ++i )
	{
		if( m_qlsReqs.at(i)->GetRequestId() == oNotify.GetRequest()->GetRequestId() )
		{
			pRequest = oNotify.GetRequest();
			m_qlsReqs.removeAt(i);
			break;
		}
	}

	if( pRequest != 0 )
	{
		QString sResult("Timeout");
		if( oNotify.GetNofifyType() == GLoadersManagerRequestNotify::eContentLoadComplete )
		{
			m_pMainView->setPage(oNotify.GetWebPage());
			sResult = "Completed";

			SetAsActive(oNotify.GetLoadersManagerId());
		}

		static QString const strTemp("RequestId(%1), has been completed with result (%2) for (%3).");
		LOG_LEVEL4(QString(strTemp) . arg(pRequest->GetRequestId()) . arg(sResult) . arg(GetSessionName(pRequest->GetSessionId())));

		if( pRequest->IsSynchronize() )
		{
			GAbsView::SignalSynchronize( (sResult=="Completed")?(true):(false) );
		}

		delete pRequest;

		ProcessNewRequest();

		return;
	}

	throw(GException("Cannot found the request in the internal queue."));
}
void GPageLoadRequestManager::InitializeMainView()
{
	LOG_LEVEL4("InitializeMainView()");

	int iWidth (0);
	int iHeight(0);

	m_pMainView = new QWebView();

	if( GETCONF_BOOL(eDisplayManagerAutoAdjustmentViewSize) )
	{
		QScreen * pScreen(QScreen::instance());

		iHeight = pScreen->deviceHeight();
		iWidth  = pScreen->deviceWidth();

		QString strTemp("Window Size detected : [");
		strTemp += QString::number(iWidth)  + "x";
		strTemp += QString::number(iHeight) + "]";

		LOG_LEVEL3(strTemp);

		SETCONF(eDisplayManagerViewHeight, QString::number(iHeight));
		SETCONF(eDisplayManagerViewWidth, QString::number(iWidth));
	}
	else
	{
		iHeight = GETCONF_NUM(eDisplayManagerViewHeight);
		iWidth  = GETCONF_NUM(eDisplayManagerViewWidth);
	}

	m_pMainView->window()->resize(iWidth, iHeight);
	m_pMainView->window()->setFixedSize(iWidth, iHeight);
	m_pMainView->window()->showFullScreen();
	SetMainViewWidth(m_pMainView->width());
	SetMainViewHeight(m_pMainView->height());

	if( (m_pMainView->width() != iWidth) && (m_pMainView->height() != iHeight) )
	{
		throw GException("One of the dimensions exceded the maximun of the screen.");
	}

	LOG_LEVEL3(QString("Width(")  + QString::number(m_pMainView->width()) + ")");
	LOG_LEVEL3(QString("Height(") + QString::number(m_pMainView->height()) + ")");
}
QSharedPointer<GURLModelSingleton> GURLModelSingleton::GetInstance() throw(GException)
{
	LOG_LEVEL3( "GetInstance()" );

    QMutexLocker oLocker(&GURLModelSingleton::m_mutex);

	if( m_pGURLModelSingleton.isNull() )
	{
		m_pGURLModelSingleton = QSharedPointer<GURLModelSingleton>(new GURLModelSingleton());
	}

	if( m_pGURLModelSingleton.isNull() )
	{
		 throw( GException("GURLModelSingleton::GetInstance() made a NULL pointer.") );
	}

	return m_pGURLModelSingleton;
}
Exemplo n.º 30
0
void	GXmlWriter::SetEncoding(G::XmlEncoding Encoding)
{
    GString find("encoding=\"" + this->_encoding + "\"");
    if (this->_xml.Find(find) != GString::NotFound)
    {
        if (Encoding == G::UTF8)
            this->_encoding = "UTF-8";
        else if (Encoding == G::ISO)
            this->_encoding = "ISO-8859-1";
        this->_xml = this->_xml.Replace(find, "encoding=\"" + this->_encoding + "\"");
    }
    else
    {
        throw GException("GXmlWriter", "Cannot find PROLOG !");
        this->_error = GXmlWriter::PROLOG_NOT_FOUND;
    }
    int pos;
    if ((pos = this->_xml.Find("]>\n")) != GString::NotFound)
        this->_pos = pos;
}