Example #1
0
void MCAdExecCreateAd(MCExecContext& ctxt, const char *p_name, MCAdType p_type, MCAdTopLeft p_top_left, MCVariableValue *p_meta_data)
{    
    bool t_success;
    t_success = true;
    
    if (s_inneractive_ad_key == nil || MCCStringLength(s_inneractive_ad_key) == 0)
    {
        ctxt.SetTheResultToStaticCString("not registered with ad service");
        t_success = false;;
    }
    
    MCAd *t_ad;
    t_ad = nil;
    
    if (t_success)
        if (MCAd::FindByNameOrId(p_name, t_ad))
        {
            ctxt.SetTheResultToStaticCString("ad already exists");
            t_success = false;
        }            
    
    if (t_success)
    {
        uint32_t t_timeout;
        if (t_success)
        {
            t_timeout = 0;
            if (p_meta_data != nil && p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "refresh", false))
                t_timeout = ctxt.GetEP().getint4();
            if (p_type == kMCAdTypeFullscreen)
                t_timeout = 0;
            else if (t_timeout < 30 || t_timeout > 500)
                t_timeout = 120;
        }
        
        if (t_success)
            t_success = MCSystemInneractiveAdCreate(ctxt, t_ad, p_type, p_top_left, t_timeout, p_meta_data);
        
        if (t_success)
            t_success = t_ad->Create();
        
        if (t_success)
        {
            t_ad->SetNext(s_ads);
            t_ad->SetName(p_name);
            t_ad->SetOwner(ctxt.GetObjectHandle());
            s_ads = t_ad;        
        }
        else if (t_ad != nil)
            t_ad->Release();
               
    }

	if (!t_success)
		ctxt.SetTheResultToStaticCString("could not create ad"); 
}
Example #2
0
void MCGetContactDataExec(MCExecContext& p_ctxt, int32_t p_contact_id)
{
    MCVariableValue *r_contact_data = nil;
    MCSystemGetContactData(p_ctxt, p_contact_id, r_contact_data);
    if (r_contact_data == nil)
        p_ctxt.SetTheResultToEmpty();
    else
        p_ctxt.GetEP().setarray(r_contact_data, True);
}
Example #3
0
bool MCSystemInneractiveAdCreate(MCExecContext &ctxt, MCAd *&r_ad, MCAdType p_type, MCAdTopLeft p_top_left, uint32_t p_timeout, MCVariableValue *p_meta_data)
{
	if (!MCAndroidInneractiveAdInitModule())
		return false;
	
    bool t_success;
    t_success = true;
        
    JNIEnv *t_env;
    t_env = MCJavaGetThreadEnv();
    jobject t_meta_data;
    t_meta_data = nil;
    if (t_success)
        t_success = MCJavaInitMap(t_env, t_meta_data);
    
    if (p_meta_data != nil)
    {
        if (t_success)
            if (p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "age", false))
                t_success = MCJavaMapPutStringToString(t_env, t_meta_data, "age", ctxt.GetEP().getcstring());  
        if (t_success)
            if (p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "distribution id", false))
                t_success = MCJavaMapPutStringToString(t_env, t_meta_data, "distribution id", ctxt.GetEP().getcstring());
        /*if (t_success)
            if (p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "external id", false))
                t_success = MCJavaMapPutStringToString(t_env, t_meta_data, "external id", ctxt.GetEP().getcstring());*/
        if (t_success)
            if (p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "gender", false))
                t_success = MCJavaMapPutStringToString(t_env, t_meta_data, "gender", ctxt.GetEP().getcstring());
        if (t_success)
            if (p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "keywords", false))
                t_success = MCJavaMapPutStringToString(t_env, t_meta_data, "keywords", ctxt.GetEP().getcstring());
        if (t_success)
            if (p_meta_data->fetch_element_if_exists(ctxt.GetEP(), "phone number", false))
                t_success = MCJavaMapPutStringToString(t_env, t_meta_data, "phone number", ctxt.GetEP().getcstring());
    }
    
    MCAd *t_ad;
    t_ad = nil;
    if (t_success)
    {
        t_ad = new MCAndroidInneractiveAd(p_type, p_top_left, p_timeout, t_meta_data);
        t_success = t_ad != nil;
    }
    
    if (t_success)
        r_ad = t_ad;
    
    if (!t_success)
        if (t_meta_data != nil)
            MCJavaFreeMap(t_env, t_meta_data);
	
    return t_success;
}