bool CIwGameUITextView::UpdateBinding(unsigned int element_name, CIwGameXomlVariable* var)
{
	// Two way binding for Zoom (passes the value back to the variable)
	if (PrevZoom != Zoom)
	{
		if (element_name == CIwGameXomlNames::Zoom_Hash)
		{
			if (var->Type == VT_Float)
				var->setValue(CIwGameString(Zoom).c_str());	// Write Value back to bound variable
			else
			if (var->Type == VT_Int)
				var->setValue(CIwGameString((int)Zoom).c_str());	// Write Value back to bound variable
			return true;
		}
	}

	if (!var->Modified || var->getValue().IsEmpty())
		return false;
	if (CIwGameUILabel::UpdateBinding(element_name, var))
		return true;

	if (element_name == CIwGameXomlNames::Zoom_Hash)
	{
		if (var->Type == VT_Float)
			setZoom(((CIwGameXomlVariableFloat*)var)->NativeValue);
		else
		if (var->Type == VT_Int)
			setZoom((float)((CIwGameXomlVariableInt*)var)->NativeValue);
#if defined(_DEBUG)
		else
			CIwGameError::LogError("Warning: Incorrect binding variable type, expected float or int for Zoom");
#endif // _DEBUG
	}
	else
	if (element_name == CIwGameXomlNames::MinZoom_Hash)
	{
		if (var->Type == VT_Float)
			setMinZoom(((CIwGameXomlVariableFloat*)var)->NativeValue);
#if defined(_DEBUG)
		else
			CIwGameError::LogError("Warning: Incorrect binding variable type, expected float for MinZoom");
#endif // _DEBUG
	}
	else
	if (element_name == CIwGameXomlNames::MaxZoom_Hash)
	{
		if (var->Type == VT_Float)
			setMaxZoom(((CIwGameXomlVariableFloat*)var)->NativeValue);
#if defined(_DEBUG)
		else
			CIwGameError::LogError("Warning: Incorrect binding variable type, expected float for MaxZoom");
#endif // _DEBUG
	}
	else
		return false;

	return true;
}
Example #2
0
bool CIwGameImage::Init(void* memory_file, int memory_file_size)
{
	CIwGameFile file;
	if (file.Open(memory_file, memory_file_size))
	{
		// Load the image
		CIwImage image;
		image.ReadFile((s3eFile*)file.getFileHandle());

		// if required format is different then convert it
		if (FormatSet && image.GetFormat() != Format)
		{
			CIwImage* new_image = ConvertToFormat(image, Format);
			Image2D = Iw2DCreateImage(*new_image);
			delete new_image;
		}
		else
			Image2D = Iw2DCreateImage(image);

		if (FilterSet)
			setFilter(Filter);

		if (Image2D == NULL || image.GetFormat() == CIwImage::FORMAT_UNDEFINED)
		{
#if defined(_DEBUG)
			CIwGameError::LogError("Error: CIwGameImage::Init() - Could not create image!");
#endif	// _DEBUG
			return false;
		}
		else
		{
			Width = Image2D->GetWidth();
			Height = Image2D->GetHeight();
#if defined(_DEBUG)
			CIwGameError::LogError("Info: CIwGameImage::Init() - Size = ", CIwGameString(memory_file_size).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Width = ", CIwGameString(Width).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Height = ", CIwGameString(Height).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Bit depth = ", CIwGameString(image.GetBitDepth()).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Format = ", CIwGameString(image.GetFormat()).c_str());
#endif	// _DEBUG
		}
	}

	// Sanity check
	if (Width <= 0 || Height <= 0 || Width > 16384 || Height > 16384)
		return false;

	State = State_Loaded;

	return true;
}
Example #3
0
//
//
//
//	VServ specific implementation
//
//
//
bool CIwGameAds::RequestAdVServ()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Build M2M request URI string
	RequestURI = "http://a.vserv.mobi/delivery/adapi.php?";
	CIwGameString urlencoded;

	RequestURI += "zoneid=";
	RequestURI += ApplicationID;
	RequestURI += "&im=";
	RequestURI += CIwGameString(UDID);
	RequestURI += "&ic=";
	RequestURI += s3eDeviceGetString(S3E_DEVICE_LOCALE);
	RequestURI += "&app=1";
	RequestURI += "&ts=1";
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	if (Width != 0)
	{
		RequestURI += "&sw=";
		RequestURI += CIwGameString(Width);
	}
	if (Height != 0)
	{
		RequestURI += "&sh=";
		RequestURI += CIwGameString(Height);
	}
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #4
0
//
//
//
//	MillennialMedia specific implementation
//
//
//
bool CIwGameAds::RequestAdMillennialMedia()
{
	// Build M2M request URI string
	//RequestURI = "http://ads.mp.mydas.mobi/getAd.php5?";
    RequestURI = "http://ads.mydas.mobi/getAd?";
	CIwGameString urlencoded;

	RequestURI += "apid=";
	RequestURI += ApplicationID;
	RequestURI += "&auid=";
	RequestURI += CIwGameString(UDID);
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
//	RequestURI += "&mode=test";
//	RequestURI += "&uip=";
//	RequestURI += IW_GAME_HTTP_MANAGER->getIPAddress();

	if (UserAge != 0)
	{
		RequestURI += "&age=";
		RequestURI += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			RequestURI += "&gender=female";
		else
			RequestURI += "&gender=male";
	}
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #5
0
//
//
//
//	AdFonic specific implementation
//
//
//
bool CIwGameAds::RequestAdAdFonic()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	CIwGameString urlencoded;

	RequestURI = "http://adfonic.net/ad/";
	RequestURI += ApplicationID;
	RequestURI += "?";
	RequestURI += "r.id=";
	urlencoded.URLEncode(CIwGameString(UDID).c_str());
	RequestURI += urlencoded;
	RequestURI += "&s.test=0";
	RequestURI += "&t.format=xml";
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #6
0
void CIwGameXmlParser::ShowError(eXMLParserError error, int pos) const
{
#ifdef SHOW_ERRORS
	s3eDebugOutputString(GetErrorString(error));
	s3eDebugOutputString(" at line ");
	CIwGameString num = CIwGameString(m_pDataInput->GetLineNumber(pos));
	s3eDebugOutputString(num.c_str());
#endif
}
Example #7
0
void CIwGameAds::AdReceived(CIwGameHttpRequest* request, int error)
{
	// If there wwas an error then set the error
	if (error != 0)
	{
		IW_GAME_ADS->setError(ErrorHttp);
		IW_GAME_ADS->setErrorString("Http error");
#if defined(_DEBUG)
		CIwGameError::LogError("Error: CIwGameAds::AdReceived(): ", CIwGameString(error).c_str());
#endif	// _DEBUG
		NotifyAdAvailable();
	}
	else
	{
#if defined(_DEBUG)
		if (request->getContentLength() > 4096)
			memcpy(g_HttpResponse, request->getContent().c_str(), 4096);
		else
			memcpy(g_HttpResponse, request->getContent().c_str(), request->getContentLength());
		g_HttpResponse[request->getContentLength()] = 0;
		CIwGameError::LogError("Info: CIwGameAds::AdReceived(): *************");
		CIwGameError::LogError((const char*)&g_HttpResponse[0]);
		CIwGameError::LogError("****************************");
#endif	// _DEBUG
		// Replace html chars
		request->getContent().ReplaceHTMLCodes();
		if (!ExtractAd(AdInfo, request->getContent()))
		{
#if defined(_DEBUG)
			CIwGameError::LogError("Error: CIwGameAds::AdReceived(): Invalid ad data");
#endif	// _DEBUG
			Error = ErrorInvalidAdData;
			NotifyAdAvailable();
			return;
		}
		if (!HtmlAds && !TextAds && AdInfo.ImageURI.GetLength() != 0)
		{
			// Download the banner ad image
			RequestBannerImage(AdInfo);
		}
		else
		{
#if defined(_DEBUG)
			if (AdInfo.ImageURI.GetLength() == 0)
			{
				CIwGameError::LogError("Error: CIwGameAds::AdReceived(): Content length is 0!");
			}
#endif	// _DEBUG
			NotifyAdAvailable();
		}
	}
}
bool CIwGameUISlider::UpdateBinding(unsigned int element_name, CIwGameXomlVariable* var)
{
	// Two way binding for Value (passes the value back to the variable)
	if (ThumbChanged)
	{
		if (element_name == CIwGameXomlNames::Value_Hash)
		{
			if (var->Type == VT_Float)
				var->setValue(CIwGameString(Value).c_str());	// Write Value back to bound variable
			return true;
		}
	}

	if (!var->Modified || var->getValue().IsEmpty())
		return false;
	if (CIwGameUIBase::UpdateBinding(element_name, var))
		return true;

	if (element_name == CIwGameXomlNames::SliderSize_Hash)
	{
		if (var->Type == VT_Int)
			SliderSize = ((CIwGameXomlVariableInt*)var)->NativeValue;
#if defined(_DEBUG)
		else
			CIwGameError::LogError("Warning: Slider Incorrect binding variable type, expected int for SliderSize");
#endif // _DEBUG
	}
	else
	if (element_name == CIwGameXomlNames::Value_Hash)
	{
		if (var->Type == VT_Float)
			setValue(((CIwGameXomlVariableFloat*)var)->NativeValue);
#if defined(_DEBUG)
		else
			CIwGameError::LogError("Warning: Slider Incorrect binding variable type, expected float for Value");
#endif // _DEBUG
	}
	else
	if (element_name == CIwGameXomlNames::ValueRange_Hash)
	{
		if (var->Type == VT_Vec2)
			ValueRange = ((CIwGameXomlVariableVec2*)var)->NativeValue;
#if defined(_DEBUG)
		else
			CIwGameError::LogError("Warning: Slider Incorrect binding variable type, expected vec2 for ValueRange");
#endif // _DEBUG
	}
	else
		return false;

	return true;
}
Example #9
0
//
//
//
//	MobFox specific implementation
//
//
//
bool CIwGameAds::RequestAdMobFox()
{
	// Build request URI string
	RequestURI = "http://my.mobfox.com/request.php";

	CIwGameString body;
	CIwGameString urlencoded;

	body = "rt=api";
	body += "&u=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
	body += "&i=";
	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&o=";
	body += CIwGameString(UDID);
	body += "&m=live";
	body += "&s=";
	body += ApplicationID;
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #10
0
void CIwGameFile::FileReceived(CIwGameHttpRequest* request, int error)
{
	// If there wwas an error then set the error
	if (error != 0)
	{
		Error = ErrorHttp;
#if defined(_DEBUG)
		CIwGameError::LogError("Error: CIwGameFile::FileReceived(): ", CIwGameString(error).c_str());
#endif	// _DEBUG
	}

	// Open the file
	Open((void*)request->getContent().c_str(), request->getContentLength());

	// Notify caller that the file is available
	NotifyAvailable();
}
Example #11
0
//
//
//
//	Mojiva specific implementation
//
//
//
bool CIwGameAds::RequestAdMojiva()
{
	// Build M2M request URI string
	RequestURI = "http://ads.mojiva.com/ad?";

	CIwGameString urlencoded;

	RequestURI += "zone=";
	RequestURI += ApplicationID;
	RequestURI += "&ip=";
	RequestURI += IW_GAME_HTTP_MANAGER->getIPAddress();
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	RequestURI += "&udid=";
	RequestURI += CIwGameString(UDID);

	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

/*	CIwGameString local = s3eDeviceGetString(S3E_DEVICE_LOCALE);
	int pos = local.Contains('_');
	if (pos >= 0)
	{
		// Strip language and underscore
		local.setString(local.c_str() + pos + 1, 2);
		local.ToUpper();
		body += "&country=";
		body += local;
	}*/

/*	if (UserAge != 0)
	{
		body += "&age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&gender=F";
		else
			body += "&gender=M";
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&keywords=";
		body += UserKeywords;
	}*/

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #12
0
//
//
//
//	ImMobi specific implementation
//
//
//
bool CIwGameAds::RequestAdInMobi()
{
	// Build M2M request URI string
	RequestURI = "http://w.inmobi.com/showad.asm";				// Live
//	RequestURI = "http://i.w.sandbox.inmobi.com/showad.asm";	// Test
    
    int slotSize = (int)SlotSize;

	CIwGameString body;
	CIwGameString urlencoded;

	body = "mk-siteid=";
	body += ApplicationID;
	body += "&mk-carrier=";
	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&h-user-agent=";
	urlencoded.URLEncode(UserAgent.c_str());
	urlencoded.ToLower();
	body += urlencoded;
	body += "&u-id=";
	body += CIwGameString(UDID);
	body += "&d-localization=";
	urlencoded.URLEncode(s3eDeviceGetString(S3E_DEVICE_LOCALE));
	urlencoded.ToLower();
	body += urlencoded;
//	body += "&d-netType=wifi";
	body += "&d-netType=carrier";
    body += "&mk-ad-slot=";
    body += CIwGameString(slotSize);
	body += "&mk-version=pr-SPEC-CTATA-20130111";
	if (UserAge != 0)
	{
		body += "&u-age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&u-gender=f";
		else
			body += "&u-gender=m";
	}
	if (!UserGPSLocation.IsEmpty())
	{
		body += "&u-latlong=";
		body += UserGPSLocation;
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&u-interests=";
		body += UserKeywords;
	}
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}
//	body.ToLower();

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("X-Mkhoj-SiteID", ApplicationID.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #13
0
//
//
//
//	Inner-Active specific implementation
//
//
//
bool CIwGameAds::RequestAdInnerActive()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Build M2M request URI string
	if (!HtmlAds)
		RequestURI = "http://m2m1.inner-active.com/simpleM2M/clientRequestAd?";
	else
		RequestURI = "http://m2m1.inner-active.com/simpleM2M/clientRequestHtmlAd?";
	RequestURI += "aid=";
	RequestURI += ApplicationID;
	RequestURI += "&po=";
	RequestURI += CIwGameString(PortalIDs[PortalType]);
	RequestURI += "&v=";
	RequestURI += Version;
	RequestURI += "&cid=";
	RequestURI += ClientID;
	RequestURI += "&hid=";
	RequestURI += CIwGameString(UDID);
	if (Width != 0)
	{
		RequestURI += "&w=";
		RequestURI += CIwGameString(Width);
	}
	if (Height != 0)
	{
		RequestURI += "&h=";
		RequestURI += CIwGameString(Height);
	}
	if (UserAge != 0)
	{
		RequestURI += "&a=";
		RequestURI += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			RequestURI += "&g=f";
		else
			RequestURI += "&g=m";
	}
	if (!UserLocation.IsEmpty())
	{
		RequestURI += "&l=";
		RequestURI += UserLocation;
	}
	if (!Category.IsEmpty())
	{
		RequestURI += "&c=";
		RequestURI += Category;
	}
	if (!UserGPSLocation.IsEmpty())
	{
		RequestURI += "&lg=";
		RequestURI += UserGPSLocation;
	}
	if (!UserMobileNumber.IsEmpty())
	{
		RequestURI += "&mn=";
		RequestURI += UserMobileNumber;
	}
	if (!UserKeywords.IsEmpty())
	{
		RequestURI += "&k=";
		RequestURI += UserKeywords;
	}
    if (!SlotSize == 0) {
        CIwGameString width;
        CIwGameString height;
        
        switch (SlotSize) {
            case 2:
                width = "168";
                height = "28";
                break;
            case 3:
                width = "216";
                height = "36";
                break;
            case 4:
                width = "300";
                height = "50";
                break;
            case 10:
                width = "300";
                height = "250";
                break;
            case 11:
                width = "728";
                height = "90";
                break;
            case 14:
                width = "320";
                height = "480";
                break;
            case 15:
                width = "320";
                height = "50";
                break;
            default:
                break;
        }
    
        RequestURI += "&ow=";
        RequestURI += width;
        RequestURI += "&oh=";
        RequestURI += height;
    }
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}
    
    

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.setBody("");
	AdRequest.SetHeader("Content-Length", "0");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #14
0
void CIwGameAds::AdImageReceived(CIwGameHttpRequest* request, int error)
{
	s3eDebugOutputString("Ad image received");
	
	// If there wwas an error then set the error
	if (error != 0)
	{
		IW_GAME_ADS->setError(ErrorHttpImage);
		IW_GAME_ADS->setErrorString("Http error retrieving image");
#if defined(_DEBUG)
		CIwGameError::LogError("Error: CIwGameAds::AdImageReceived(): ", CIwGameString(error).c_str());
#endif	// _DEBUG
	}
	else
	{
		eIwGameImageFormat format = GetImageFormatFromHeader();
		if (format == ImageFormatInvalid)
		{
			Error = ErrorInvalidImage;
			ErrorString = "Invalid image format";
		}
		else
		{
			Error = ErrorNone;
			ErrorString = "";

			AdInfo.ImageFormat = format;
#if defined(_DEBUG)
			CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Image format - ", CIwGameString((int)format).c_str());
			CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Image URL - ", AdInfo.ImageURI.c_str());
			CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Link URL - ", AdInfo.LinkURI.c_str());
#endif	// _DEBUG

			// Delete previous image (if any)
			if (AdInfo.Image != NULL)
			{
				delete AdInfo.Image;
				AdInfo.Image = NULL;
			}

			// Create new banner image
			AdInfo.Image = new CIwGameImage();
			if (!AdInfo.Image->Init((void*)request->getContent().c_str(), request->getContentLength()))
			{
#if defined(_DEBUG)
				CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Could hot create image!");
#endif	// _DEBUG
				Error = ErrorInvalidImage;
				ErrorString = "Invalid image format";
				delete AdInfo.Image;
				AdInfo.Image = NULL;
			}
			else
			{
CIwGameError::LogError("Info: Image Width - ", CIwGameString(AdInfo.Image->getWidth()).c_str());
CIwGameError::LogError("Info: Image Height - ", CIwGameString(AdInfo.Image->getHeight()).c_str());
			}
		}
	}
	NotifyAdAvailable();
}
Example #15
0
bool CIwGameAds::RequestAd(eAdProvider provider, bool reset_mediator)
{
#if defined(_DEBUG)
	CIwGameError::LogError("Info: CIwGameAds::RequestAd()");
#endif	// _DEBUG

#if defined(_DEBUG)
	CIwGameError::LogError("Info: Busy, cant request ad - Elapsed = ", CIwGameString((int)BusyTimer.GetElapsedTime()).c_str());
#endif	// _DEBUG
	// Dont allow request if busy already collecting ad or timeout has not occured
	if (BusyTimer.hasStarted())
	{
		return false;
	}

	// If we have an attached mediator then get details from the mediator
	if (Mediator != NULL)
	{
		// reset the mediator
		if (reset_mediator)
			Mediator->reset();

		// Set up custom ad request from mediator
		CIwGameAdsParty* party = Mediator->getNextAdParty();
		if (party != NULL)
		{
			provider = party-> Provider;
			ApplicationID = party-> ApplicationID;
            IOSAppID = party-> IOSAppID;
            AndroidAppID = party -> AndroidAppID;
            BBAppID = party -> BBAppID;
            WP8AppID = party -> WP8AppID;
            
			OtherID = party->OtherID;
			ExtraInfo = party->ExtraInfo;
		}
        
	}
    
    switch (OperatingSystem)
	{
        case  S3E_OS_ID_OSX:
            if (!IOSAppID.IsEmpty()) {
                ApplicationID = IOSAppID;
            }
            break;
        case  S3E_OS_ID_ANDROID:
            if (!AndroidAppID.IsEmpty()) {
                ApplicationID = AndroidAppID;
            }
            break;
        case  S3E_OS_ID_QNX:
            if (!BBAppID.IsEmpty())
            {
                ApplicationID = BBAppID;
            }
            break;
        case  S3E_OS_ID_WP8:
            if (!WP8AppID.IsEmpty())
            {
            ApplicationID = WP8AppID;
            }
            break;
    }
    
    
	// Reset error
	Error = ErrorNone;
	ErrorString = "";
	AdAvailable = false;
	AdProvider = provider;
	switch (AdProvider)
	{
	case InnerActive:
		RequestAdInnerActive();
		break;
	case AdFonic:
		RequestAdAdFonic();
		break;
	case VServ:
		RequestAdVServ();
		break;
	case Mojiva:
		RequestAdMojiva();
		break;
	case MillennialMedia:
		RequestAdMillennialMedia();
		break;
	case AdModa:
		RequestAdAdModa();
		break;
	case InMobi:
		RequestAdInMobi();
        break;
#if defined(_AD_DO_NOT_USE_)
	case MobClix:
		RequestAdMobClix();
		break;
	case MobFox:
		RequestAdMobFox();
		break;
	case Madvertise:
		RequestAdMadvertise();
		break;
	case KomliMobile:
		RequestAdKomliMobile();
		break;
#endif	// _AD_DO_NOT_USE_
	}

#if defined(_DEBUG)
	CIwGameError::LogError("Info: CIwGameAds::RequestAd() with URL: ", RequestURI.c_str());
#endif	// _DEBUG

	return true;
}
Example #16
0
bool CIwGameAds::RequestAdMadvertise()
{
	// Build M2M request URI string
	RequestURI = "http://ad.madvertise.de/site/";
	RequestURI += ApplicationID;

	CIwGameString body;
	CIwGameString urlencoded;

	body += "ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
//	body += "&ip=";
//	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&requester=madvertise_api";
	body += "&version=api_2.1";
	body += "&unique_device_id=";
	body += CIwGameString(UDID);
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}

/*	CIwGameString local = s3eDeviceGetString(S3E_DEVICE_LOCALE);
	int pos = local.Contains('_');
	if (pos >= 0)
	{
		// Strip language and underscore
		local.setString(local.c_str() + pos + 1, 2);
		local.ToUpper();
		body += "&country=";
		body += local;
	}*/

	if (UserAge != 0)
	{
		body += "&age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&gender=F";
		else
			body += "&gender=M";
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&keywords=";
		body += UserKeywords;
	}

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Example #17
0
eXMLParserError CIwGameXmlParser::Parse(CIwGameXmlNode* parent)
{
	CIwList<CIwGameXmlNode*>* parent_stack = new CIwList<CIwGameXmlNode*>();
	
	parent_stack->push_back(parent);
	int		count = NextFreePoolTagIndex;
	int		tag_index = 0;
	char*	c_data = m_pDataInput->getData();

	parent = parent_stack->back();

	while (tag_index < MarkerCount)
	{
		if (parent == NULL)
			break;
		CIwGameXmlTagMarker* marker = Marker + tag_index;
		const char* data = c_data + marker->Start;
		int len = marker->Length;

		if (*data == '<' && *(data + len - 1) == '>')
		{
			if (*(data + 1) == '/')
			{
				// Found an end tag, check that name matches parents
				int et_offset = 0;
				int et_len = GetNextWord(data + 2, et_offset);
				if (et_len <= 0)
				{
					CIwGameError::LogError("CIwGameXmlParser::Parse - Invalid close tag");
					return eXMLParserError_InvalidTag;
				}
				if (!parent->Name.Compare(data + et_offset + 2, et_len))
				{
					CIwGameError::LogError("CIwGameXmlParser::Parse - Mismatched end tag - ", parent->Name.c_str());
					CIwGameError::LogError("CIwGameXmlParser::Parse - Instead found - ", CIwGameString(data, et_offset + 2, et_len).c_str());
					return eXMLParserError_MismatchedEndTag;
				}
				for (CIwList<CIwGameXmlNode*>::iterator it = parent_stack->begin(); it != parent_stack->end(); it++)
				{
					CIwGameXmlNode* node = *it;
					if (node == parent)
					{
						parent_stack->erase(it);
						parent = parent_stack->back();
						break;
					}
				}
				tag_index++;
			}
			else
			{
				// Create a node
				CIwGameXmlNode* node = AllocNode();
				int offset;
				int nlen = GetNextWord(data + 1, offset);
				if (nlen <= 0)
					return eXMLParserError_InvalidTag;
				node->Name.setString(data + offset + 1, nlen);
				if ((len - 2) > nlen)
					ParseAttributes(data + offset + nlen + 1, len - nlen - offset - 1, node);
				parent->AddChild(node);

				if (*(data + len - 2) != '/')		// Self closing tags dont get added as parents
				{
					parent_stack->push_back(node);	// Found an inner tag so push parent
					parent = parent_stack->back();
				}

				// Check next line to see if it is a tag or a value
				tag_index++;
				if (tag_index != (NextFreePoolTagIndex - 1))
				{
					CIwGameXmlTagMarker* marker2 = Marker + tag_index;
					const char* data2 = c_data + marker2->Start;
					int len2 = marker2->Length;

					if (*data2 != '<')
					{
						// Found a value
						node->Value.setString(data2, len2);
						node->HasValue = true;
					}
				}
			}
		}
		else
			tag_index++;
	}

	parent_stack->clear();
	delete parent_stack;

	return eXMLParserError_None;
}
Example #18
0
CIwGameString CIwGameString::getSubString(int start, int max_chars)
{
	if ((start + max_chars) > Length)
		max_chars -= (start + max_chars) - Length;
	return CIwGameString(Data, start, max_chars);
}