コード例 #1
0
ファイル: exec-array.cpp プロジェクト: alilloyd/livecode
void MCArraysExecCombineAsSet(MCExecContext& ctxt, MCArrayRef p_array, MCStringRef p_element_delimiter, MCStringRef& r_string)
{
	// String into which the combined keys are accumulated
    MCAutoStringRef t_string;
    
    // The array keys are not added in any particular order
    MCNameRef t_key;
    MCValueRef t_value_ignored;
    uintptr_t t_iterator = 0;
    while (MCArrayIterate(p_array, t_iterator, t_key, t_value_ignored))
    {
        bool t_success;
        t_success = true;
        if (*t_string == nil)
            t_success = MCStringMutableCopy(MCNameGetString(t_key), &t_string);
        else
            t_success = MCStringAppendFormat(*t_string, "%@%@", p_element_delimiter, t_key);
        
        if (!t_success)
        {
            ctxt . Throw();
            return;
        }
    }
    
    MCStringCopy(*t_string, r_string);
}
コード例 #2
0
ファイル: w32ans.cpp プロジェクト: alilloyd/livecode
static void getfilter(MCStringRef p_filter, MCStringRef &r_filter)
{
	if (p_filter != nil && !MCStringIsEmpty(p_filter))
	{
		static MCAutoStringRef t_filterstring;

		if (*t_filterstring != nil)
			MCValueRelease(*t_filterstring);

		/* UNCHECKED */ MCStringMutableCopy(p_filter, &t_filterstring);
		
		uindex_t t_offset;

		if (!MCStringFirstIndexOfChar(*t_filterstring, '\n', 0, kMCStringOptionCompareExact, t_offset) &&
				!MCStringFirstIndexOfChar(*t_filterstring, ',', 0, kMCStringOptionCompareExact, t_offset))
		{
			MCStringAppendChar(*t_filterstring, '\0');
			MCStringAppend(*t_filterstring, p_filter);
		}

		/* UNCHECKED */ MCStringAppendChar(*t_filterstring, '\0');
		/* UNCHECKED */ MCStringFindAndReplaceChar(*t_filterstring, '\n', '\0', kMCStringOptionCompareExact);
		/* UNCHECKED */ MCStringFindAndReplaceChar(*t_filterstring, ',', '\0', kMCStringOptionCompareExact);

		MCStringCopy(*t_filterstring, r_filter);
	}
	else
		/* UNCHECKED */ MCStringCreateWithNativeChars((const char_t *)"All Files (*.*)\0*.*\0", 20, r_filter);
}
コード例 #3
0
bool MCSystemPickMedia(MCMediaType p_types, bool p_multiple, MCStringRef& r_result)
{
    s_media_status = kMCAndroidMediaWaiting;
    
    bool t_audio, t_video;
    t_audio = (kMCMediaTypeAnyAudio & p_types) != 0;
    t_video = (kMCMediaTypeAnyVideo & p_types) != 0;
    
    if (t_audio && !t_video)
	{
        MCAndroidEngineCall("pickMedia", "vs", nil, "audio/*");
	}
	else if (!t_audio && t_video)
	{
        MCAndroidEngineCall("pickMedia", "vs", nil, "video/*");
	}
    else
	{
        MCAndroidEngineCall("pickMedia", "vs", nil, "audio/* video/*");
	}
    
    while (s_media_status == kMCAndroidMediaWaiting)
        MCscreen->wait(60.0, False, True);
    /* UNCHECKED */ MCStringCopy(s_media_content, r_result);
    //    MCLog("Media Types Returned: %s", s_media_content);
}
コード例 #4
0
ファイル: mblandroidstore.cpp プロジェクト: alilloyd/livecode
bool MCStoreReceiveProductDetails(MCStringRef p_purchase_id, MCStringRef &r_result)
{    
    MCAutoStringRef t_result;
    
    MCAndroidEngineRemoteCall("storeReceiveProductDetails", "xx", &(&t_result), p_purchase_id);
    
    return MCStringCopy(*t_result, r_result);    
}
コード例 #5
0
ファイル: exec-array.cpp プロジェクト: alilloyd/livecode
void MCArraysExecCombine(MCExecContext& ctxt, MCArrayRef p_array, MCStringRef p_element_delimiter, MCStringRef p_key_delimiter, MCStringRef& r_string)
{
	bool t_success;
	t_success = true;

	uindex_t t_count;
	t_count = MCArrayGetCount(p_array);

	MCAutoStringRef t_string;
	if (t_success)
		t_success = MCStringCreateMutable(0, &t_string);

	combine_array_t t_lisctxt;
    t_lisctxt . elements = nil;
	if (t_success)
		t_success = MCMemoryNewArray(t_count, t_lisctxt . elements);

	if (t_success)
	{
        t_lisctxt . index = 0;
        MCArrayApply(p_array, list_array_elements, &t_lisctxt);
		qsort(t_lisctxt . elements, t_count, sizeof(array_element_t), compare_array_element);
		for(uindex_t i = 0; i < t_count; i++)
		{
			MCAutoStringRef t_value_as_string;
            
            t_success = ctxt . ConvertToString(t_lisctxt . elements[i] . value, &t_value_as_string);
            if (!t_success)
                break;

			t_success =
				(p_key_delimiter == nil ||
                    (MCStringAppend(*t_string, MCNameGetString(t_lisctxt . elements[i] . key)) &&
					MCStringAppend(*t_string, p_key_delimiter)))&&
				MCStringAppend(*t_string, *t_value_as_string) &&
				(i == t_count - 1 ||
					MCStringAppend(*t_string, p_element_delimiter));

			if (!t_success)
				break;
		}
	}
	
	if (t_success)
		t_success = MCStringCopy(*t_string, r_string);

	MCMemoryDeleteArray(t_lisctxt . elements);

	if (t_success)
		return;

	// Throw the current error code (since last library call returned false).
	ctxt . Throw();
}
コード例 #6
0
void MCAndroidMediaDone(MCStringRef p_media_content)
{
#ifdef /* MCAndroidMediaDone */ LEGACY_EXEC
    s_media_content = p_media_content;
    //    MCLog("MCAndroidMediaDone() called %s", p_media_content);
	s_media_status = kMCAndroidMediaDone;
#endif /* MCAndroidMediaDone */
    MCStringCopy(p_media_content, s_media_content);
    //    MCLog("MCAndroidMediaDone() called %s", p_media_content);
	s_media_status = kMCAndroidMediaDone;
}
コード例 #7
0
ファイル: w32ans.cpp プロジェクト: alilloyd/livecode
static void get_new_filter(MCStringRef *p_types, uint4 p_type_count, MCStringRef &r_filters)
{
	MCAutoStringRef t_filters;
	/* UNCHECKED */ MCStringCreateMutable(0, &t_filters);

	for(uint4 t_type_index = 0; t_type_index < p_type_count; ++t_type_index)
	{
		MCAutoStringRefArray t_split;
		/* UNCHECKED */ MCStringsSplit(p_types[t_type_index], '|', t_split.PtrRef(), t_split.CountRef());

		if (t_split.Count() < 1 || 
			(t_split.Count() == 1 && MCStringIsEmpty(t_split[0])))
			continue;

		if (t_type_index != 0)
			/* UNCHECKED */ MCStringAppendChar(*t_filters, '\0');

		/* UNCHECKED */ MCStringAppend(*t_filters, t_split[0]);

		if (t_split.Count() < 2)
			/* UNCHECKED */ MCStringAppendChars(*t_filters, L"\0*.*", 4);
		else
		{
			MCAutoStringRefArray t_extensions;
			/* UNCHECKED */ MCStringsSplit(t_split[1], ',', t_extensions.PtrRef(), t_extensions.CountRef());
			// SN-2014-07-28: [[ Bug 12972 ]] Filters "Tag|" should be understood as "Tag"
			//  and allow all the file types
			if (t_extensions.Count() == 0 || 
					(t_extensions.Count() == 1 && MCStringIsEmpty(t_extensions[0])))
				/* UNCHECKED */ MCStringAppendChars(*t_filters, L"\0*.*", 4);
			else
			{
				for (unsigned int i = 0; i < t_extensions.Count(); ++i)
				{
					if (i != 0)
						/* UNCHECKED*/ MCStringAppendChar(*t_filters, ';');
					else
						/* UNCHECKED*/ MCStringAppendChar(*t_filters, '\0');

					/* UNCHECKED */ MCStringAppendFormat(*t_filters, "*.%@", t_extensions[i]);
				}
			}
		}
	}

	if (MCStringIsEmpty(*t_filters))
		/* UNCHECKED */ MCStringCreateWithNativeChars((char_t*)"All Files\0*.*\0\0", 15, r_filters);
	else
	{
		/* UNCHECKED */ MCStringAppendChar(*t_filters, '\0');
		MCStringCopy(*t_filters, r_filters);
	}
}
コード例 #8
0
ファイル: srvsession.cpp プロジェクト: alilloyd/livecode
bool MCSessionOpenIndex(MCSessionIndexRef &r_index)
{
	bool t_success = true;
	
	MCSessionIndexRef t_index = nil;

	t_success = MCMemoryNew(t_index);
	
	MCAutoStringRef t_save_path;
	if (t_success)
		t_success = MCS_get_session_save_path(&t_save_path);
	
	if (t_success)
        t_success = MCStringCopy(*t_save_path, t_index->save_path);
	
	MCAutoStringRef t_path_string;
	if (t_success)
        t_success = MCStringFormat(&t_path_string, "%@/lcsessions.idx", t_index->save_path);
	
	// open file
	if (t_success)
		t_success = NULL != (t_index->file = MCsystem->OpenFile(*t_path_string, kMCOpenFileModeUpdate, false));

	// lock file
	if (t_success)
		t_success = MCSystemLockFile(t_index->file, false, true);
	
	// read index
	if (t_success && t_index->file->GetFileSize() > 0)
		t_success = MCSessionReadIndex(t_index);
	
	if (t_success)
		r_index = t_index;
	else
		MCSessionCloseIndex(t_index, false);
	
	return t_success;
}
コード例 #9
0
ファイル: w32ans.cpp プロジェクト: alilloyd/livecode
static void build_paths(MCStringRef &r_path)
{
	MCAutoStringRef t_path;
	/* UNCHECKED */ MCStringCreateMutable(0, &t_path);
	MCAutoStringRef t_std_path;
	MCAutoStringRef t_native_path;
	/* UNCHECKED */ MCStringCreateWithChars(s_chosen_folder.Ptr(), s_chosen_folder.Size()-1, &t_native_path);
	/* UNCHECKED */ MCS_pathfromnative(*t_native_path, &t_std_path);

	if (MCStringGetCharAtIndex(*t_std_path, 0) == '"')
	{
		// Does this ever actually receive a quoted path?
		/*Meta::itemised_string t_items(sg_chosen_files, ' ', true);
		for(unsigned int t_index = 0; t_index < t_items . count(); ++t_index)
		{
			if (t_index != 0)
				/* UNCHECKED * / MCStringAppendChar(*t_path, '\n');

			build_path(*t_std_path, t_items[t_index], *t_path);
		}*/
		MCAutoStringRef t_item;
		/* UNCHECKED */ MCStringCreateWithChars(s_chosen_files.Ptr(), s_chosen_files.Size()-1, &t_item);
		build_path(*t_std_path, *t_item, *t_path);
	}
	else
	{
		MCAutoStringRef t_files;
		/* UNCHECKED */ MCStringCreateWithChars(s_chosen_files.Ptr(), s_chosen_files.Size()-1, &t_files);
		build_path(*t_std_path, *t_files, *t_path);
	}

	s_chosen_files.Delete();
	s_chosen_folder.Delete();

	MCStringCopy(*t_path, r_path);
}
コード例 #10
0
ファイル: license.cpp プロジェクト: soapdog/livecode
void MCLicenseGetRevLicenseInfo(MCExecContext& ctxt, MCStringRef& r_info)
{
    static const char *s_deploy_targets[] =
    {
        "Windows",
        "Mac OS X",
        "Linux",
        "iOS",
        "Android",
        "Windows Mobile",
        "Linux Mobile",
        "Server",
        "iOS Embedded",
        "Android Embedded",
        "HTML5",
        "FileMaker",
    };
    
    bool t_success;
    
    MCAutoStringRef t_info;
    t_success = MCStringCreateMutable(0, &t_info);
    
    MCStringRef t_license_name;
    t_license_name = MClicenseparameters . license_name;
    if (t_license_name == nil)
        t_license_name = kMCEmptyString;

    MCStringRef t_license_org;
    t_license_org = MClicenseparameters . license_organization;
    if (t_license_org == nil)
        t_license_org = kMCEmptyString;

    MCAutoStringRef t_class;
    if (t_success)
        t_success = MCStringFromLicenseClass(MClicenseparameters . license_class, false, &t_class);
    
    if (t_success)
        t_success = MCStringAppendFormat(*t_info, "%@\n%@\n%@\n%u\n",
                                         t_license_name, t_license_org,
                                         *t_class,
                                         MClicenseparameters . license_multiplicity);
    
    if (MClicenseparameters . deploy_targets != 0)
    {
        bool t_first;
        t_first = true;
        for(uint32_t i = 0; t_success && i < sizeof(s_deploy_targets) / sizeof(s_deploy_targets[0]); i++)
        {
            if ((MClicenseparameters . deploy_targets & (1 << i)) != 0)
            {
                t_success = MCStringAppendFormat(*t_info, t_first ? "%s" : ",%s", s_deploy_targets[i]);
                t_first = false;
            }
        }
    }
    
    // AL-2014-11-04: [[ Bug 13865 ]] Don't add an extra line between deploy targets and addons

    if (t_success && MClicenseparameters . addons != nil)
    {
        MCAutoStringRef t_keys;
        t_success = (MCArrayListKeys(MClicenseparameters . addons, ',', &t_keys) &&
                    MCStringAppendFormat(*t_info, "\n%@", *t_keys));
    }
    
    if (t_success)
        if (MCStringAppendFormat(*t_info, "\n%s", MCStringIsEmpty(MClicenseparameters . license_token) ? "Global" : "Local") &&
                MCStringCopy(*t_info, r_info))
            return;
    
    ctxt . Throw();
}
コード例 #11
0
ファイル: rtf.cpp プロジェクト: alilloyd/livecode
RTFStatus RTFReader::Flush(bool p_force)
{
	RTFStatus t_status;
	t_status = kRTFStatusSuccess;

	if (!m_attributes_changed && !p_force)
		return t_status;

	MCTextBlock t_block;
	bool t_changed;
	t_changed = false;
	if (m_attributes_changed)
	{
		t_block . foreground_color = m_state . GetForegroundColor();
		t_block . background_color = m_state . GetBackgroundColor();
		t_block . font_name = m_state . GetFontName();
		if (m_state . GetFontSize() != 0)
			t_block . font_size = half_points_to_pixels(m_state . GetFontSize());
		else
			t_block . font_size = 0;
		
		t_block . font_style = FA_DEFAULT_STYLE;
		if ((m_state . GetFontStyle() & kRTFFontStyleItalic) != 0)
			t_block . font_style |= FA_ITALIC;
		if ((m_state . GetFontStyle() & kRTFFontStyleBold) != 0)
			t_block . font_style |= FA_BOLD;
		if ((m_state . GetFontStyle() & kRTFFontStyleUnderline) != 0)
			t_block . font_style |= FA_UNDERLINE;
		if ((m_state . GetFontStyle() & kRTFFontStyleStrikethrough) != 0)
			t_block . font_style |= FA_STRIKEOUT;
		if ((m_state . GetFontStyle() & kRTFFontStyleLink) != 0)
			t_block . font_style |= FA_LINK;

		if ((m_state . GetFontStyle() & kRTFFontStyleSuperscript) != 0)
			t_block . text_shift = -4;
		else if ((m_state . GetFontStyle() & kRTFFontStyleSubscript) != 0)
			t_block . text_shift = 4;
		else
			t_block . text_shift = 0;
		
		if (m_state . GetHyperlink() != kMCEmptyName)
			MCNameClone(m_state . GetHyperlink(), t_block . text_link);
		else
			t_block . text_link = nil;

        if (m_state . GetMetadata() != kMCEmptyString)
            /* UNCHECKED */ MCStringCopy(m_state . GetMetadata(), t_block . text_metadata);
		else
			t_block . text_metadata = MCValueRetain(kMCEmptyString);

		t_block . string_native = false;
		t_block . string_buffer = NULL;
		t_block . string_length = 0;

		if (t_block . foreground_color != m_attributes . foreground_color ||
			t_block . background_color != m_attributes . background_color ||
			t_block . font_size != m_attributes . font_size ||
			t_block . font_style != m_attributes . font_style ||
			t_block . text_shift != m_attributes . text_shift ||
			CStringCompare(t_block . font_name, m_attributes . font_name) != 0 ||
			t_block . text_link != m_attributes . text_link ||
			t_block . text_metadata != m_attributes . text_metadata)
			t_changed = true;
	}

	const uint2 *t_string_buffer;
	uint4 t_string_length;
	if (t_status == kRTFStatusSuccess)
		t_status = m_text . Borrow(t_string_buffer, t_string_length);

	if (t_status == kRTFStatusSuccess && t_string_length > 0 && (t_changed || p_force))
	{
		if (m_needs_paragraph)
		{
			m_needs_paragraph = false;

			// MW-2012-03-14: [[ RtfParaStyles ]] Use the 'Paragraph()' method to ensure
			//   paragraph styles get applied.
			Paragraph();
		}

		m_attributes . string_native = false;
		m_attributes . string_buffer = t_string_buffer;
		m_attributes . string_length = t_string_length / 2;
		m_converter(m_converter_context, NULL, &m_attributes);
		m_text . Clear();
	}

	if (t_changed)
	{
        MCValueRelease(m_attributes . text_metadata);
        MCNameDelete(m_attributes . text_link);
		memcpy(&m_attributes, &t_block, sizeof(MCTextBlock));
		m_attributes_changed = false;
	}

	return t_status;
}