Exemplo n.º 1
0
Exec_stat MCHandleControlDo(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_control_name;
	char *t_action_name;
	t_control_name = nil;
	t_action_name = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "ss", &t_control_name, &t_action_name);
	
	MCNativeControl *t_control;
	MCNativeControlAction t_action;
	if (t_success)
		t_success =
		MCNativeControl::FindByNameOrId(t_control_name, t_control) &&
		MCNativeControl::LookupAction(t_action_name, t_action);
	
	if (t_success)
		t_success = t_control -> Do(t_action, p_parameters) == ES_NORMAL;
	
	delete t_action_name;
	delete t_control_name;
	
	return ES_NORMAL;
}
Exemplo n.º 2
0
Exec_stat MCHandleControlSet(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_control_name;
	char *t_prop_name;
	t_control_name = nil;
	t_prop_name = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "ss", &t_control_name, &t_prop_name);
	
	MCNativeControl *t_control;
	MCNativeControlProperty t_property;
	if (t_success)
		t_success =
		MCNativeControl::FindByNameOrId(t_control_name, t_control) &&
		MCNativeControl::LookupProperty(t_prop_name, t_property);
	
	MCExecPoint ep(nil, nil, nil);
	if (t_success && p_parameters != nil)
		t_success = p_parameters -> eval(ep);
	
	if (t_success)
		t_success = t_control -> Set(t_property, ep) == ES_NORMAL;
	
	delete t_prop_name;
	delete t_control_name;
	
	return ES_NORMAL;
}
Exemplo n.º 3
0
Exec_stat MCHandleControlGet(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_control_name;
	char *t_prop_name;
	t_control_name = nil;
	t_prop_name = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "ss", &t_control_name, &t_prop_name);
	
	MCNativeControl *t_control;
	MCNativeControlProperty t_property;
	if (t_success)
		t_success =
		MCNativeControl::FindByNameOrId(t_control_name, t_control) &&
		MCNativeControl::LookupProperty(t_prop_name, t_property);
	
	MCExecPoint ep(nil, nil, nil);
	if (t_success)
		t_success = t_control -> Get(t_property, ep) == ES_NORMAL;
	
	if (t_success)
		MCresult -> store(ep, True);
	else
		MCresult -> clear();
	
	delete t_prop_name;
	delete t_control_name;
	
	return ES_NORMAL;
	
}
Exemplo n.º 4
0
Exec_stat MCHandleAdSetTopLeft(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
    char *t_top_left_string;
    t_top_left_string = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "ss", &t_ad, &t_top_left_string);
    
    MCAdTopLeft t_top_left = {0,0};
    if (t_success)
        t_success = sscanf(t_top_left_string, "%u,%u", &t_top_left.x, &t_top_left.y);
    
	if (t_success)
		MCAdSetTopLeftOfAd(t_ctxt, t_ad, t_top_left);
    
    MCCStringFree(t_top_left_string);
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Exemplo n.º 5
0
bool MCContactParseParams(MCParameter *p_params, MCVariableValue *&r_contact, char *&r_title, char *&r_message, char *&r_alternate_name)
{
	bool t_success = true;
	
	MCVariableValue *t_contact = nil;
	char *t_title = nil;
	char *t_message = nil;
	char *t_alternate_name = nil;
	
	t_success = MCParseParameters(p_params, "a|sss", &t_contact, &t_title, &t_message, &t_alternate_name);
	
	if (t_success)
	{
		r_contact = t_contact;
		r_title = t_title;
		r_message = t_message;
		r_alternate_name = t_alternate_name;
	}
	else
	{
		MCCStringFree(t_title);
		MCCStringFree(t_message);
		MCCStringFree(t_alternate_name);
	}
	
	return t_success;
}
Exemplo n.º 6
0
Exec_stat MCHandleAdGetVisible(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);
	
    bool t_visible;
    t_visible = false;
	if (t_success)
		t_success = MCAdGetVisibleOfAd(t_ctxt, t_ad, t_visible);
    
    if (t_success)
        MCresult->sets(MCU_btos(t_visible));
    
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Exemplo n.º 7
0
Exec_stat MCHandleAdGetTopLeft(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);
	
    MCAdTopLeft t_top_left = {0,0};
	if (t_success)
		t_success = MCAdGetTopLeftOfAd(t_ctxt, t_ad, t_top_left);
    
    if (t_success)
    {
        MCAutoRawCString t_top_left_string;
        t_success = MCCStringFormat(t_top_left_string, "%u,%u", t_top_left.x, t_top_left.y);
        if (t_success)
            if (t_top_left_string.Borrow() != nil)
                ep.copysvalue(t_top_left_string.Borrow());
    }
    
    if (t_success)
        MCresult->store(ep, False);
    
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Exemplo n.º 8
0
Exec_stat MCHandleSetAllowedOrientations(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_orientations;
	t_orientations = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_orientations);
	
	char **t_orientations_array;
	uint32_t t_orientations_count;
	t_orientations_array = nil;
	t_orientations_count = 0;
	if (t_success)
		t_success = MCCStringSplit(t_orientations, ',', t_orientations_array, t_orientations_count);
	
	uint32_t t_orientations_set;
	t_orientations_set = 0;
	if (t_success)
		for(uint32_t i = 0; i < t_orientations_count; i++)
			for(uint32_t j = 0; s_orientation_names[j] != nil; j++)
				if (MCCStringEqualCaseless(t_orientations_array[i], s_orientation_names[j]))
					t_orientations_set |= (1 << j);
	
	s_allowed_orientations = t_orientations_set;
	
	for(uint32_t i = 0; i < t_orientations_count; i++)
		MCCStringFree(t_orientations_array[i]);
	MCMemoryDeleteArray(t_orientations_array);
	
	MCCStringFree(t_orientations);
	
	return ES_NORMAL;
}
Exemplo n.º 9
0
Exec_stat MCHandleControlDelete(void *context, MCParameter *p_parameters)
{
#ifdef /* MCHandleControlDelete */ LEGACY_EXEC
	bool t_success;
	t_success = true;
	
	char *t_control_name;
	t_control_name = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_control_name);
	
	MCNativeControl *t_control;
	if (t_success)
		t_success = MCNativeControl::FindByNameOrId(t_control_name, t_control);
	
	if (t_success)
	{
		t_control -> Delete();
		t_control -> Release();
	}
	
	delete t_control_name;
	
	return ES_NORMAL;
#endif /* MCHandleControlDelete */
}
Exemplo n.º 10
0
Exec_stat MCHandleAdCreate(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
		
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    	
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);	
    
    MCAdType t_type;
    t_type = kMCAdTypeUnknown;
    if (t_success)
    {
        char *t_type_string;
        t_type_string = nil;
        if (MCParseParameters(p_parameters, "s", &t_type_string))
            t_type = MCAdTypeFromCString(t_type_string);
        MCCStringFree(t_type_string);
    }
    
    MCAdTopLeft t_top_left = {0,0};
    if (t_success)
    {
        char *t_top_left_string;
        t_top_left_string = nil;
        if (MCParseParameters(p_parameters, "s", &t_top_left_string))
            /* UNCHECKED */ sscanf(t_top_left_string, "%u,%u", &t_top_left.x, &t_top_left.y);
        MCCStringFree(t_top_left_string);
    }
    
    MCVariableValue *t_meta_data;
    t_meta_data = nil;
    if (t_success)
        MCParseParameters(p_parameters, "a", &t_meta_data);

	if (t_success)
		MCAdExecCreateAd(t_ctxt, t_ad, t_type, t_top_left, t_meta_data);
    
    MCCStringFree(t_ad);
	    
    return t_ctxt.GetStat();
}
Exemplo n.º 11
0
Exec_stat MCHandleAddContact(void *context, MCParameter *p_parameters)
{
    MCExecPoint ep(nil, nil, nil);
    // Handle parameters. We are doing that in a dedicated call
	MCVariableValue *t_contact;
	
	/* UNCHECKED */ MCParseParameters(p_parameters, "a", &t_contact);

    MCExecContext t_ctxt(ep);
    // Call the Exec implementation
    MCAddContactExec(t_ctxt, t_contact);
    // Set return value
    return t_ctxt.GetStat();
}
Exemplo n.º 12
0
Exec_stat MCHandleRevMail(void *context, MCParameter *p_parameters)
{
	char *t_address, *t_cc_address, *t_subject, *t_message_body;
	t_address = nil;
	t_cc_address = nil;
	t_subject = nil;
	t_message_body = nil;
	
	MCExecPoint ep(nil, nil, nil);
	
	MCParseParameters(p_parameters, "|ssss", &t_address, &t_cc_address, &t_subject, &t_message_body);
	
	s_mail_status = kMCAndroidMailWaiting;
	MCAndroidSendEmail(t_address, t_cc_address, t_subject, t_message_body);

	while (s_mail_status == kMCAndroidMailWaiting)
		MCscreen->wait(60.0, False, True);

	switch (s_mail_status)
	{
		case kMCAndroidMailSent:
			MCresult -> sets("sent");
			break;
			
		case kMCAndroidMailCanceled:
			MCresult -> sets("cancel");
			break;
			
		case kMCAndroidMailUnknown:
		default:
			MCresult -> sets("unknown");
			break;
	}
	
	delete t_address;
	delete t_cc_address;
	delete t_subject;
	delete t_message_body;
	
	return ES_NORMAL;
}
Exemplo n.º 13
0
Exec_stat MCHandleAdDelete(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);
	
	if (t_success)
		MCAdExecDeleteAd(t_ctxt, t_ad);
    
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Exemplo n.º 14
0
Exec_stat MCHandleAdRegister(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_key;
	t_key = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_key);
	
	if (t_success)
		MCAdExecRegisterWithInneractive(t_ctxt, t_key);
    
    MCCStringFree(t_key);
    
    return t_ctxt.GetStat();
}
Exemplo n.º 15
0
Exec_stat MCHandleControlCreate(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_type_name;
	t_type_name = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_type_name);
	
	char *t_control_name;
	t_control_name = nil;
	if (t_success && p_parameters != nil)
		t_success = MCParseParameters(p_parameters, "s", &t_control_name);
	
	// Make sure the name is valid.
	if (t_success && t_control_name != nil)
	{
		if (MCCStringIsEmpty(t_control_name))
		{
			delete t_control_name;
			t_control_name = nil;
		}
		else
			t_success = !MCCStringIsInteger(t_control_name);
	}
	
	// Make sure a control does not already exist with the name
	if (t_success && t_control_name != nil)
	{
		MCNativeControl *t_control;
		t_success = !MCNativeControl::FindByNameOrId(t_control_name, t_control);
	}
	
	MCNativeControlType t_type;
	if (t_success)
		t_success = MCNativeControl::LookupType(t_type_name, t_type);
	
	MCNativeControl *t_control;
	t_control = nil;
	if (t_success)
		t_success = MCNativeControl::CreateWithType(t_type, t_control);
	
	if (t_success)
	{
		extern MCExecPoint *MCEPptr;
		t_control -> SetOwner(MCEPptr -> getobj());
		t_control -> SetName(t_control_name);
		MCresult -> setnvalue(t_control -> GetId());
	}
	else
	{
		if (t_control != nil)
			t_control -> Delete();
		
		MCresult -> clear();
	}
	
	delete t_control_name;
	delete t_type_name;
	
	return ES_NORMAL;
}
Exemplo n.º 16
0
Exec_stat MCHandleComposeMail(MCMailType p_type, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_to, *t_cc, *t_bcc;
	MCString t_subject, t_body;
	MCVariableValue *t_attachments;
	t_to = t_cc = t_bcc = nil;
	t_attachments = nil;
	
	if (t_success)
		t_success = MCParseParameters(p_parameters, "|dsssda", &t_subject, &t_to, &t_cc, &t_bcc, &t_body, &t_attachments);

	if (t_success)
	{
		//MCLog("mail type: %d", p_type);
		//MCLog("subject: %d: \"%s\"", t_subject.getlength(), t_subject.getstring());
		//MCLog("body: %d: \"%s\"", t_body.getlength(), t_body.getstring());
		const char *t_prep_sig;
		if (p_type == kMCMailTypeUnicode)
			t_prep_sig = "vsssUUb";
		else
			t_prep_sig = "vsssSSb";

		MCAndroidEngineCall("prepareEmail", t_prep_sig, nil, t_to, t_cc, t_bcc, &t_subject, &t_body, p_type == kMCMailTypeHtml);

		// add attachments
		if (t_attachments != nil)
		{
			MCVariableArray *t_array;
			t_array = t_attachments -> get_array();
			if (t_array -> isnumeric())
			{
				for(uint32_t i = 0; i < t_array -> getnfilled(); i++)
				{
					MCHashentry *t_entry;
					t_entry = t_array -> lookupindex(i + 1, False);
					if (t_entry == nil)
						continue;
					if (!t_entry -> value . is_array())
						continue;
						
					MCString t_data;
					MCString t_file;
					MCString t_type;
					MCString t_name;
					if (array_to_attachment(t_entry -> value . get_array(), t_data, t_file, t_type, t_name))
					{
						//MCLog("file: %p: %d: \"%s\"", &t_file, t_file.getlength(), t_file.getstring() != nil ? t_file.getstring() : "NULL");
						//MCLog("data: %p: %d: \"...\"", &t_data, t_data.getlength());
						//MCLog("type: %p: %d: \"%s\"", &t_type, t_type.getlength(), t_type.getstring() != nil ? t_type.getstring() : "NULL");
						//MCLog("name: %p: %d: \"%s\"", &t_name, t_name.getlength(), t_name.getstring() != nil ? t_name.getstring() : "NULL");
						if (t_file.getlength() > 0)
							MCAndroidEngineCall("addAttachment", "vSSS", nil, &t_file, &t_type, &t_name);
						else
							MCAndroidEngineCall("addAttachment", "vdSS", nil, &t_data, &t_type, &t_name);
					}
				}
			}
			else
			{
				MCString t_data;
				MCString t_file;
				MCString t_type;
				MCString t_name;
				if (array_to_attachment(t_array, t_data, t_file, t_type, t_name))
				{
					if (t_file.getlength() > 0)
						MCAndroidEngineCall("addAttachment", "vSSS", nil, &t_file, &t_type, &t_name);
					else
						MCAndroidEngineCall("addAttachment", "vdSS", nil, &t_data, &t_type, &t_name);
				}
			}
		}

		MCAndroidEngineCall("sendEmail", "v", nil);
	}
	
	while (s_mail_status == kMCAndroidMailWaiting)
		MCscreen->wait(60.0, False, True);
	
	switch (s_mail_status)
	{
		case kMCAndroidMailSent:
			MCresult -> sets("sent");
			break;
			
		case kMCAndroidMailCanceled:
			MCresult -> sets("cancel");
			break;
			
		case kMCAndroidMailUnknown:
		default:
			MCresult -> sets("unknown");
			break;
	}
	
	delete t_subject . getstring();
	MCCStringFree(t_to);
	MCCStringFree(t_cc);
	MCCStringFree(t_bcc);
	delete t_body . getstring();
	
	return ES_NORMAL;
}