Example #1
0
void MCRemoveContactExec(MCExecContext& p_ctxt, int32_t p_contact_id)
{
    if (MCSystemRemoveContact(p_contact_id))
		p_ctxt.SetTheResultToNumber(p_contact_id);
	else
        p_ctxt.SetTheResultToEmpty();
}
Example #2
0
void MCAddContactExec(MCExecContext &ctxt, MCVariableValue *p_contact)
{
	int32_t t_result = 0;
	/* UNCHECKED */ MCSystemAddContact(p_contact, t_result);
	if (t_result > 0)
		ctxt.SetTheResultToNumber(t_result);
	else
		ctxt.SetTheResultToEmpty();
}
Example #3
0
void MCUpdateContactExec(MCExecContext& p_ctxt, MCVariableValue *p_contact, const char *p_title, const char *p_message, const char *p_alternate_name)
{
    int32_t r_result = 0;
    /* UNCHECKED */ MCSystemUpdateContact(p_contact, p_title, p_message, p_alternate_name, r_result);
    if (r_result > 0)
        p_ctxt.SetTheResultToNumber(r_result);
    else
        p_ctxt.SetTheResultToEmpty();
}
Example #4
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 #5
0
void MCCreateContactExec(MCExecContext& p_ctxt)
{
    int32_t r_result = 0;
    MCSystemCreateContact(r_result);
    if (r_result > 0)
        p_ctxt.SetTheResultToNumber(r_result);
    else
        p_ctxt.SetTheResultToEmpty();
}
Example #6
0
void MCShowContactExec(MCExecContext& p_ctxt, int32_t p_contact_id)
{
    int32_t r_result = 0;
    MCSystemShowContact(p_contact_id, r_result);
    if (r_result > 0)
        p_ctxt.SetTheResultToNumber(r_result);
    else
        p_ctxt.SetTheResultToEmpty();
}
Example #7
0
void MCFindContactExec(MCExecContext& p_ctxt, const char* p_contact_name)
{
    char *t_result;
    t_result = nil;
    MCSystemFindContact(p_contact_name, t_result);
    if (t_result != nil)
        p_ctxt.SetTheResultToCString(t_result);
    else
        p_ctxt.SetTheResultToEmpty();
    MCCStringFree(t_result);
}
Example #8
0
void MCSecurityEvalRandomBytes(MCExecContext& ctxt, uinteger_t p_byte_count, MCDataRef& r_bytes)
{
	if (!InitSSLCrypt())
	{
		ctxt.LegacyThrow(EE_SECURITY_NOLIBRARY);
		return;
	}

	if (MCSRandomData (p_byte_count, r_bytes))
	{
		ctxt.SetTheResultToEmpty();
		return;
	}
	
	ctxt.SetTheResultToCString("error: could not get random bytes");
}
Example #9
0
void MCPickExecPickOptionByIndex(MCExecContext &ctxt, int p_chunk_type, MCStringRef *p_option_lists, uindex_t p_option_list_count, uindex_t *p_initial_indices, uindex_t p_indices_count, bool p_use_hilite_type, bool p_use_picker, bool p_use_cancel, bool p_use_done, MCRectangle p_button_rect)
{
    
    MCAutoArray<MCPickList> t_pick_lists;
    
    char_t t_delimiter;
    switch ((MCChunkType)p_chunk_type)
    {
        // No access to the line/item delimiter set in the handler from the mobile-specific functions/commands
        // so following the old engine default values for them
        case kMCChunkTypeItem:
            t_delimiter = ',';
            break;
        case kMCChunkTypeWord:
        case kMCChunkTypeLine:
            t_delimiter = '\n';
            break;
        default:
            MCUnreachable();
    }
    uindex_t t_old_offset = 0;
    uindex_t t_new_offset = 0;
    
    bool t_success;
    t_success = true;
    
    for (uindex_t i = 0; i < p_option_list_count; i++)
    {
        MCStringRef t_option;
        MCPickList t_pick_list;
        MCAutoArray<MCStringRef> t_options;
        t_old_offset = 0;
        
        while (t_success && MCStringFirstIndexOfChar(p_option_lists[i], t_delimiter, t_old_offset, kMCCompareCaseless, t_new_offset))
        {
            t_success = MCStringCopySubstring(p_option_lists[i], MCRangeMakeMinMax(t_old_offset, t_new_offset), t_option);
            if (t_success)
                t_options . Push(t_option);
            
            t_old_offset = t_new_offset + 1;
        }
        // Append the remaining part of the options
        t_success = MCStringCopySubstring(p_option_lists[i], MCRangeMakeMinMax(t_old_offset, MCStringGetLength(p_option_lists[i])), t_option);
        if (t_success)
            t_options . Push(t_option);
        
        t_options . Take(t_pick_list . options, t_pick_list . option_count);
        t_pick_list . initial = p_initial_indices[i];
        t_pick_lists . Push(t_pick_list);
    }
    
    bool t_cancelled;
    
    uindex_t *t_result;
    uindex_t t_result_count = 0;
    
    // Open the picker and allow the user to select the options
    if (t_success)
        t_success = MCSystemPickOption(t_pick_lists . Ptr(), t_pick_lists . Size(), t_result, t_result_count, p_use_hilite_type, p_use_picker, p_use_cancel, p_use_done, t_cancelled, p_button_rect);
    
    ctxt.SetTheResultToEmpty();
    
    if (t_success)
    {
        if (t_cancelled)
        {
            // HC-2012-02-15 [[ BUG 9999 ]] Picker should return 0 if cancel was selected.
            ctxt . SetTheResultToNumber(0);
        }
        else
        {
            MCAutoListRef t_indices;
            t_success = MCListCreateMutable(',', &t_indices);
            for (uindex_t i = 0; i < t_result_count && t_success; i++)
            {
                MCAutoStringRef t_index;
                t_success = MCStringFormat(&t_index, "%u", t_result[i]);
                if (t_success)
                    t_success = MCListAppend(*t_indices, *t_index);
            }
            MCAutoStringRef t_string;
			/* UNCHECKED */ MCListCopyAsString(*t_indices, &t_string);
            ctxt . SetTheResultToValue(*t_string);
        }
    }
    
    // Free memory
    for (uindex_t i = 0; i < t_pick_lists . Size(); i++)
        for (uindex_t j = 0; j < t_pick_lists[i] . option_count; j++)
            MCValueRelease(t_pick_lists[i] . options[j]);
}