Beispiel #1
0
/**
 * Evaluate a Lua script.
 * @param script String with Lua code.
 * @return Non-zero if successful, zero on error.
 */
int LuaEngine::eval(const char* script)
{
	lua_State* L = (lua_State*) mLuaState;

	// Evaluate Lua script.
	int result = luaL_dostring(L, script);

	// Was there an error?
	if (0 != result)
	{
		MAUtil::String errorMessage;

    	if (lua_isstring(L, -1))
    	{
    		errorMessage = lua_tostring(L, -1);

            // Pop the error message.
        	lua_pop(L, 1);
    	}
    	else
    	{
    		errorMessage =
    			"There was a Lua error condition, but no error message.";
    	}

        lprintfln("Lua Error: %s\n", errorMessage.c_str());

    	// Print size of Lua stack (debug info).
    	lprintfln("Lua stack size: %i\n", lua_gettop(L));

    	reportLuaError(errorMessage.c_str());
	}

	return result == 0;
}
Beispiel #2
0
/**
 * Helper function that unescapes a string.
 */
static MAUtil::String UnescapeHelper(const MAUtil::String& str)
{
	// The decoded string.
	MAUtil::String result = "";

	for (int i = 0; i < str.length(); ++i)
	{
		// If the current character is the '%' escape char...
		if ('%' == (char) str[i])
		{
			// Get the char value of the two digit hex value.
			MAUtil::String hex = str.substr(i + 1, 2);
			long charValue = strtol(
				hex.c_str(),
				NULL,
				16);
			// Append to result.
			result += (char) charValue;

			// Skip over the hex chars.
			i += 2;
		}
		else
		{
			// Not encoded, just copy the character.
			result += str[i];
		}
	}

	return result;
}
Beispiel #3
0
    /**
     * Check if the local notification is playing sound.
     * @return True if the local notification is playing sound when it's
     * shown, false otherwise.
     */
    bool LocalNotification::isPlayingSound() const
    {
        MAUtil::String value =
            this->getPropertyString(MA_NOTIFICATION_LOCAL_PLAY_SOUND);

        return (0 == strcmp(value.c_str(), "true")) ? true : false;
    }
Beispiel #4
0
	/**
	 * Check if the reorder control is shown.
	 * The reordering control is gray, multiple horizontal bar control
	 * on the right side of the cell.
	 * Platform: iOS.
	 * @return true if it's shown, false otherwise.
	 */
	bool SegmentedListViewItem::isReorderControlShown()
	{
		MAUtil::String value = this->getPropertyString(
			MAW_SEGMENTED_LIST_VIEW_ITEM_SHOW_REORDER_CONTROL);
		bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
		return returnValue;
	}
Beispiel #5
0
// Reads a log file from a s60v3 debug runtime.
static bool tryToRead() {
	MAUtil::String filename = "C:/Data/msrlogold.txt";
	printf("Open '%s'\n", filename.c_str());
	MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ);
	if(file < 0) {
		printf("Error %i\n", file);
		return false;
	}
	int res = maFileExists(file);
	MAASSERT(res >= 0);
	if(!res) {
		printf("File does not exist.\n");
		return false;
	}
	int size = maFileSize(file);
	printf("Size: %i\n", size);
	MAASSERT(size >= 0);
	static char data[32*1024];
	MAASSERT(size < (int)sizeof(data));
	res = maFileRead(file, data, size);
	MAASSERT(res == 0);
	data[32] = 0;
	printf("%s\n", data);
	printf("Closing...\n");
	res = maFileClose(file);
	MAASSERT(res == 0);
	printf("Done.\n");
	return true;
}
Beispiel #6
0
	/**
	* This function is called when an event that Moblet doesn't recognize is recieved.
	*/
	void TestMoblet::customEvent(const MAEvent& event)
	{
		if ( event.type == EVENT_TYPE_ALERT)
		{
//			printf("\n =========== Alert Event received ======\n");
			MAUtil::String temp = "";
			switch( event.alertButtonIndex)
			{
			case 1:
				temp += "First ";
				break;
			case 2:
				temp += "Second ";
				break;
			case 3:
				temp += "Third ";
				break;
			default:
				temp = "err";
			}
			temp += " button was clicked";
//			maMessageBox("Alert Event received", temp.c_str());
			printf(temp.c_str());
			printf("\n ------------- This was all ------------- \n");
		}

	}
Beispiel #7
0
	/**
	 * Check if the item is currently showing the delete-confirmation button.
	 * When users tap the deletion control (the red circle to the left of
	 * the cell), the cell displays a "Delete" button on the right side of
	 * the cell.
	 * Platform: iOS.
	 * @return True if it's showing the delete confirmation button, false
	 * otherwise.
	 */
	bool SegmentedListViewItem::isShowingDeleteConfirmation()
	{
		MAUtil::String value = this->getPropertyString(
			MAW_SEGMENTED_LIST_VIEW_ITEM_IS_SHOWING_DELETE_CONFIRMATION);
		bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
		return returnValue;
	}
Beispiel #8
0
/*
 * Adds a Post object to a to a User wall.
 * @param message - the message to be posted
 * @param link - the link to be included in post.
 * @param pictureUrl - a picture url to be included in post.
 * @param actions - a Vector of Action objects (objects containing name and link) to be included in the post.
 * @param id - the id of the user on which wall the post will be displayed.
 */
void FacebookPublisher2::addPostOnWall(const MAUtil::String &ID, const MAUtil::String &message, const MAUtil::String &link,
			const MAUtil::String &name, const MAUtil::String &caption, const MAUtil::String &description )
{
	MAUtil::Map<MAUtil::String, MAUtil::String> params;

	MAUtil::String postdata = "message=" + message;

	if(link.size()>0)
	{
		postdata += mPostdataSeparator + "link=" + link;
	}

//	if(pictureUrl.size()>0)
//	{
//		postdata += mPostdataSeparator + "picture=" + pictureUrl;
//	}
	if(name.size()>0)
	{
		postdata += mPostdataSeparator + "name=" + name;
	}
	if(caption.size()>0)
	{
		postdata += mPostdataSeparator + "caption=" + caption;
	}
	if(description.size()>0)
	{
		postdata += mPostdataSeparator + "description=" + description;
	}

	mFacebook->requestGraph(PUBLISH, STRING, ID + "/feed", HTTP_POST, postdata);
}
Beispiel #9
0
	/**
	 * This method is called when the Submit button is clicked, or edit box
	 * return button was hit.
	 */
	void MainScreen::submitEditBoxContent()
	{
		// Get the text from the password box.
		MAUtil::String password = mPasswordBox->getText();

		// Check if the text doesn't fit the buffer( the default size is 256).
		if ( mPasswordBox->getLastError().errorCode ==
				MAW_RES_INVALID_STRING_BUFFER_SIZE )
		{
			// If the password is too long we use the instructions label
			// to inform the user. Note that C automatically concatenates
			// strings split over multiple lines.
			mInstructions->setText("Password too long. "
				"Please enter a shorter password:"******"Password too short. "
				"Please enter a password of at least 6 characters:");
		}
		else
		{
			// The password is at least 6 characters long,
			// we congratulate user.
			mInstructions->setText("Password OK");
		}
	}
Beispiel #10
0
/*
 * Adds a Event object for a User.
 * @param PROFILE_ID - the id of the User to which the event is added.
 * @param eventName - the name of the event.
 * @param eventStartTime - the start time of the Event.
 * @param eventEndTime - the end time of the Event.
 * @param message - the message to be posted alog with the event
 * @param location - the name of the location
 * @param privacyType - a string that can have the following values: "PUBLIC",
 */
void FacebookPublisher2::addEvent(const MAUtil::String &PROFILE_ID,		const MAUtil::String &name,
									const UnixTimeStamp &start_time,	const UnixTimeStamp &end_time,
									const MAUtil::String &message,		const MAUtil::String &location,
									const MAUtil::String &privacyType)
{
	MAUtil::String postdata = "name=" + name;

	postdata += mPostdataSeparator;
	postdata += "start_time=";
	postdata += start_time.getTimeStamp();


	if(!end_time.isEmpty())
	{
		postdata += mPostdataSeparator;
		postdata += "end_time=";
		postdata += end_time.getTimeStamp();
	}

	if(message.size()>0)
	{
		postdata += mPostdataSeparator + "message=" + message;
	}
	if(location.size()>0)
	{
		postdata += mPostdataSeparator + "location=" + location;
	}
	if(privacyType.size()>0)
	{
		postdata += mPostdataSeparator + "privacy_type =" + privacyType;
	}

	mFacebook->requestGraph(PUBLISH, STRING, PROFILE_ID + "/events", HTTP_POST, postdata);
}
Beispiel #11
0
/*
 * Adds a Checkin object for a User
 * @param PROFILE_ID - the id of the User for which the Checkin object is created.
 * @param placeId - the id of the place to which the checkin is made.
 * @param coord - the coordinates of the checkin place.
 * @param tags - list of tagged friends. String containing comma separated list of user id's.
 * @param message - the message that will be posted along with the Checkin
 */
void FacebookPublisher2::addCheckin(const MAUtil::String &PROFILE_ID,	const MAUtil::String &placeId,
									const Coordinate &coord,			const MAUtil::String &tags,
									const MAUtil::String &message)
{

	MAUtil::Map<MAUtil::String, MAUtil::String> params;

	params["place"] = placeId;

	MAUtil::String coordStr = "{\"latitude\":\"" + coord.mLatitude +"\",";
	coordStr += "\"longitude\":\"" + coord.mLongitude + "\"}";

	params["coordinates"] = coordStr;

	MAUtil::String postdata = "method=POST" + mPostdataSeparator;
	postdata += "place=";
	postdata += placeId + mPostdataSeparator;
	postdata += coordStr;
	if(tags.size()>0)
	{
		postdata = mPostdataSeparator + "tags=" + tags;
	}
	if(message.size()>0)
	{
		postdata = mPostdataSeparator + "message=" + message;
	}

	mFacebook->requestGraph(PUBLISH, STRING, PROFILE_ID + "/checkins", HTTP_POST, params, postdata);
}
Beispiel #12
0
void ImageCache::httpFinished(MAUtil::HttpConnection* http, int result) {
	if (result == 200) {
		MAUtil::String *contentLengthStr = new MAUtil::String("-1");
		int responseBytes = mHttp.getResponseHeader("content-length", contentLengthStr);
		mContentLength = 0;
		mDataOffset = 0;
		mData = maCreatePlaceholder();
		if(responseBytes == CONNERR_NOHEADER) {

		} else {
			mContentLength = atoi(contentLengthStr->c_str());
		}
		delete contentLengthStr;
		if (maCreateData(mData, mContentLength) == RES_OK){

		}

		if(mContentLength >= 1024 || mContentLength == 0) {
			mHttp.recv(mBuffer, 1024);
		} else {
			mBuffer[mContentLength] = 0;
			mHttp.recv(mBuffer, mContentLength);
		}
	}
	else {
		finishedDownloading();
	}
}
Beispiel #13
0
	bool ListView::isSelectionAllowed()
	{
		MAUtil::String value = this->getPropertyString(
			MAW_LIST_VIEW_ALLOW_SELECTION);
		bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
		return returnValue;
	}
Beispiel #14
0
void SMV::buttonClicked(Widget* button)
{
	mEditBox->hideKeyboard();

	MAUtil::String str;
	str = mEditBox->getText();
	strcpy(engine->url_path, str.c_str());
	int str_c = strlen(engine->url_path);
	if(engine->url_path[str_c-1] != '/')
	{
		engine->url_path[str_c++] = '/';
		engine->url_path[str_c] = '\0';
		//mEditBox->setText(engine->url_path);
	}

	MAHandle directory = maFileOpen(engine->url_path, MA_ACCESS_READ);
	if (directory < 0)
		maMessageBox("Uwaga!", "Blad FileOpen!");
	else
	{
		if (!maFileExists(directory))
			maMessageBox("Uwaga!", "Katalog nie istnieje!");
		else
		{
			maWidgetScreenShow(0);
			int res = maLocationStart();
			if(res<0)	maPanic(1, "No GPS available");
			engine->read_conf_file();
			engine->env_init();
			engine->draw();
		}
	}
}
Beispiel #15
0
void Login::actionSubmit(const MAUtil::String& mail, const MAUtil::String& pwd)
{
	auth_token = "";
	memset(buffer, 0, sizeof(buffer));

	int res = mHttp.create((MAUtil::String(Manager::main->host) + "/" + qLogin).c_str(), HTTP_POST);

	if (res < 0)
	{
		manager->view->callbackAuthentication();
		return;
	}

	// escape input
	static MAUtil::String jsonQuery;
	jsonQuery = "{\"email\": " + Wormhole::Encoder::JSONStringify(mail.c_str()) + ", \"password\": " + Wormhole::Encoder::JSONStringify(pwd.c_str()) + "}";

	mHttp.setRequestHeader("Accept", "application/json");
	mHttp.setRequestHeader("Content-type", "application/json");

	char buf[32];
	sprintf(buf, "%d", jsonQuery.size());

	mHttp.setRequestHeader("Content-length", buf);

	mHttp.write(jsonQuery.c_str(), jsonQuery.size());
}
Beispiel #16
0
/*
 * Read the only string from one string resource.
 * Note: The parameter pos is used both for input and output
 * of the position in the resource data.
 * @param resID A valid resource id.
 * @param pos In: The start position. Out: The position
 * after the string in the resource.
 * @param output The resulting string.
 */
bool ScreenImageSwiper::readStringFromResource(
	MAHandle resID,
	int& pos,
	MAUtil::String& output) const
{
	// Get all the characters on one read.

	// Get the length of the string stored as a .pstring
	// (Pascal string). The first byte contains the length.
	byte stringLen = 0;
	maReadData(resID, (void*) &stringLen, pos, sizeof(byte));
	if (stringLen > maGetDataSize(resID) || stringLen <= 0)
	{
		return false;
	}

	// Read the string.
	pos += sizeof(byte);
	output.resize(stringLen);
	maReadData(resID, (void*) output.c_str(), pos, stringLen);

	// Update position to the byte after the string.
	pos += stringLen;

	return true;
}
Beispiel #17
0
	/**
	 * Reads the CountryTable file.
	 * Data will be written into mCountryFileNames.
	 */
	void DatabaseManager::readCountryTableFile()
	{
		// Reset array.
		mCountryFileNames.clear();

		// Open CountryTable file.
		MAUtil::String filePath = mFileUtil->getLocalPath() + COUNTRY_TABLE_FILE_NAME;
		MAUtil::String fileContent;
		if (!mFileUtil->readTextFromFile(filePath, fileContent))
		{
			printf("Cannot read text from CountryTable");
			return;
		}

		//Read file content.
		MAUtil::YAJLDom::Value* root = MAUtil::YAJLDom::parse(
			(const unsigned char*)fileContent.c_str(), fileContent.size());
		MAUtil::YAJLDom::Value* countries = root->getValueForKey(sCountriesKey);
		MAUtil::YAJLDom::ArrayValue* countriesArray = (MAUtil::YAJLDom::ArrayValue*) countries;
		MAUtil::Vector<MAUtil::YAJLDom::Value*> allCountries = countriesArray->getValues();

		// Get all country files that we should read next.
		for (int index = 0; index < allCountries.size(); index++)
		{
			MAUtil::YAJLDom::Value* countryValue = allCountries[index];
			MAUtil::String countryFileName = countryValue->toString();
			mCountryFileNames.add(countryFileName);
		}
		delete root;
	}
Beispiel #18
0
/**
 * Modify the first value of the address field.
 * Set a custom label for that value.
 */
void PIMContact::modifyAddressField()
{
    printf("==============Modify address field=============\n\n");
    mArgs.field = MA_PIM_FIELD_CONTACT_ADDR;

    // Print new value on the screen.
    for (int i = 0; i < COUNT_ADDRESS_INDICES; i++)
    {
        MAUtil::String addressValueIndex = getAddressIndexString(i);
        const wchar* addressValue = sAddressModified[i];
        printf("%s %S", addressValueIndex.c_str(), addressValue);
    }
    printf("\n");

    // Write the address into the buffer.
    mArgs.bufSize = writeWCharArraysToBuf(
                        mArgs.buf,
                        sAddressModified,
                        COUNT_ADDRESS_INDICES);

    // Set the value for the address field at position 0.
    // Use MA_PIM_ATTR_ADDR_CUSTOM so we can set the label later.
    checkResultCode(maPimItemSetValue(&mArgs, 0, MA_PIM_ATTR_ADDR_CUSTOM));

    // Set custom attribute(label) for the above address.
    printf("\n Set label for the this address.");
    printf("Label: %S", sAddressLabel);

    // Write label value into buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sAddressLabel);

    // Set label value for address field at position 0.
    checkResultCode(maPimItemSetLabel(&mArgs, 0));
    waitForClick();
}
Beispiel #19
0
void BenchDBConnector::httpFinished(MAUtil::HttpConnection* http, int result) {
	printf("HTTP %i\n", result);
	if(result == 200){//everything went fine
		lprintfln("MoSync benchmark DONE!");
	}

	MAUtil::String contentLengthStr;
	int responseBytes = mHttp.getResponseHeader("content-length", &contentLengthStr);
	int contentLength = 0;
	if(responseBytes == CONNERR_NOHEADER)
		printf("no content-length response header\n");
	else {
		printf("content-length : %s\n", contentLengthStr.c_str());
		contentLength = atoi(contentLengthStr.c_str());
	}
	if(contentLength >= CONNECTION_BUFFER_SIZE || contentLength == 0) {
		printf("Receive in chunks..\n");
		mHttp.recv(mBuffer, CONNECTION_BUFFER_SIZE);
	} else {
		mBuffer[contentLength] = 0;
		mHttp.read(mBuffer, contentLength);
		printf("response: %s\n", mBuffer);
	}

}
Beispiel #20
0
/**
 * Add values to email field.
 */
void PIMContact::addEmail()
{
    printf("Add values to email field.\n\n");
    MAUtil::String attribute;
    mArgs.field = MA_PIM_FIELD_CONTACT_EMAIL;

    // Print home email value and attribute for on the screen.
    attribute = getEmailAttributeString(MA_PIM_ATTR_EMAIL_HOME);
    printf("Attribute: %s", attribute.c_str());
    printf("Email: %S", sEmailHome);

    // Write home email value to buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sEmailHome);

    // Add value to the email field.
    checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_EMAIL_HOME));
    printf("\n");

    // Print work email value and attribute for on the screen.
    attribute = getEmailAttributeString(MA_PIM_ATTR_EMAIL_WORK);
    printf("Attribute: %s", attribute.c_str());
    printf("Email: %S", sEmailWork);

    // Write work email value to buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sEmailWork);

    // Add value to the email field.
    checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_EMAIL_WORK));
}
Beispiel #21
0
	/**
	 * Check if the item is highlighted.
	 * Platform: iOS.
	 * @return True if highlighted, false otherwise.
	 */
	bool SegmentedListViewItem::isHighlighted()
	{
		MAUtil::String value = this->getPropertyString(
			MAW_SEGMENTED_LIST_VIEW_ITEM_IS_HIGHLIGHTED);
		bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
		return returnValue;
	}
Beispiel #22
0
/**
 * Add values to URL field.
 */
void PIMContact::addURL()
{
    MAUtil::String attribute;
    printf("Add values to URL field.\n\n");
    mArgs.field = MA_PIM_FIELD_CONTACT_URL;

    // Print home URL value and attribute.
    attribute = getWebsiteAttributeString(MA_PIM_ATTR_WEBSITE_HOME);
    printf("Attribute: %s", attribute.c_str());
    printf("URL1: %S", sURLHome);

    // Write home URL value to buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sURLHome);

    // Add value to URL field.
    checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_WEBSITE_HOME));
    printf("\n");

    // Print work URL value and attribute.
    attribute = getWebsiteAttributeString(MA_PIM_ATTR_WEBSITE_WORK);
    printf("Attribute: %s", attribute.c_str());
    printf("URL2: %S", sURLWork);

    // Write work URL value to buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sURLWork);

    // Add value to URL field.
    checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_WEBSITE_WORK));
}
Beispiel #23
0
	/**
	 * Get the editable state.
	 * Platform: iOS.
	 * @return true if the cell can be edit, false otherwise.
	 */
	bool SegmentedListViewItem::isEditable()
	{
		MAUtil::String value = this->getPropertyString(
			MAW_SEGMENTED_LIST_VIEW_ITEM_EDIT);
		bool returnValue = (strcmp(value.c_str(), "true")) ? false : true;
		return returnValue;
	}
Beispiel #24
0
/**
 * Add values to relation field.
 */
void PIMContact::addRelation()
{
    printf("Add values to relation field.\n\n");
    mArgs.field = MA_PIM_FIELD_CONTACT_RELATION;
    MAUtil::String attribute;

    // Print brother relation value and attribute.
    attribute = getRelationAttributeString(MA_PIM_ATTR_RELATION_BROTHER);
    printf("Attribute: %s", attribute.c_str());
    printf("Relation1: %S", sRelationBrother);

    // Write brother value to buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sRelationBrother);

    // Add value to relation field.
    checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_RELATION_BROTHER));
    printf("\n");

    // Print manager relation value and attribute.
    attribute = getRelationAttributeString(MA_PIM_ATTR_RELATION_MANAGER);
    printf("Attribute: %s", attribute.c_str());
    printf("Relation2: %S", sRelationManager);

    // Write manager value to buffer.
    mArgs.bufSize = copyWCharArray(mArgs.buf, sRelationManager);

    // Add value to relation field.
    checkResultCode(maPimItemAddValue(&mArgs, MA_PIM_ATTR_RELATION_MANAGER));
}
Beispiel #25
0
/**
 * Helper function that escapes a string.
 */
static MAUtil::String EscapeHelper(const MAUtil::String& str)
{
	// The encoded string.
	MAUtil::String result = "";
    char buf[8];

    for (int i = 0; i < str.length(); ++i)
    {
    	char c = str[i];
        if ((48 <= c && c <= 57) ||  // 0-9
            (65 <= c && c <= 90) ||  // a..z
            (97 <= c && c <= 122))   // A..Z
        {
        	result.append(&str[i], 1);
        }
        else
        {
        	result += "%";
            sprintf(buf, "%02X", str[i]);
            result += buf;
        }
    }

    return result;
}
Beispiel #26
0
/**
 * This method is called if the touch-up event was inside the
 * bounds of the button.
 * @param button The button object that generated the event.
 */
void MainScreen::buttonClicked(Widget* button)
{
	if (button == mSetTextButton)
	{
		mEditBox->setText("DEFAULT");
	}
	else if (button == mGetTextButton)
	{
		mGetTextLabel->setText(mEditBox->getText());

		MAUtil::String text = mEditBox->getText();
		printf("get text = %s", text.c_str());
	}
	else if (button == mKeyboardButton)
	{
		mKeyboard = !mKeyboard;
		if (mKeyboard)
		{
			mEditBox->showKeyboard();
		}
		else
		{
			mEditBox->hideKeyboard();
		}
	}
}
Beispiel #27
0
XML::XML(MAUtil::String filename)
{
	MAUtil::String file = getLocalPath()+filename;

	file += ".xml";

	fname = file;

	XML::file = maFileOpen(file.c_str(), MA_ACCESS_READ_WRITE);

	int res = maFileExists(XML::file);

	if(res == 1)
	{
		maFileTruncate(XML::file, 0);
	}
	else if(res == 0)
	{
		maFileCreate(XML::file);
	}
	else
	{
		maPanic(0, "Error on file creation.");
	}

	CreateRoot(filename);

	_ActivityIndicator = new WaitMessage("Please, wait...", "Saving data to file.");
}
Beispiel #28
0
	/**
	 * Here we handle events from the web view. We turn on or off
	 * location tracking depending of the message sent from JavaScript.
	 */
	void handleWidgetEvent(MAWidgetEventData* widgetEvent)
	{
		// Handle messages from the WebView widget.
		if (MAW_EVENT_WEB_VIEW_HOOK_INVOKED == widgetEvent->eventType)
		{
			// Get message content, this is the url set in JavaScript.
			MAUtil::String message = Util::createTextFromHandle(
				widgetEvent->urlData);

			// Note: It is very important to free the data handle
			// when we are done with using it, since a new data object
			// is allocated for each message. (In the high-level library
			// this is done automatically.)
			maDestroyPlaceholder(widgetEvent->urlData);

			// Check the message string and execute the corresponding syscall.
			if (0 == message.find("StartTrackingGeoLocation"))
			{
				maLocationStart();
			}
			else
			if (0 == message.find("StopTrackingGeoLocation"))
			{
				maLocationStop();
			}
		}
	}
Beispiel #29
0
    /**
     * Check if the local notification has vibrate enabled.
     * Platform: Android.
     * @return True if the user will be alerted with a vibration,
     * false otherwise.
     */
    bool LocalNotification::isVibrateEnabled() const
    {
        MAUtil::String value =
            this->getPropertyString(MA_NOTIFICATION_LOCAL_VIBRATE);

        return (0 == strcmp(value.c_str(), "true")) ? true : false;
    }
Beispiel #30
0
static bool tryToWrite(const MAUtil::String& dir) {
    MAUtil::String filename = dir + "test.txt";
    printf("Open '%s'\n", filename.c_str());
    MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ_WRITE);
    if(file < 0) {
        printf("Error %i\n", file);
        return false;
    }
    int res = maFileExists(file);
    MAASSERT(res >= 0);
    if(res) {
        printf("File exists.\n");
    } else {
        printf("Creating file...\n");
        res = maFileCreate(file);
        if(res < 0) {
            printf("Error %i\n", res);
            return false;
        }
    }
    static const char data[] = "asfihu89ph4nma98fjioan9phadf89h239hdad9h89p\n";
    printf("Writing %lu bytes...\n", sizeof(data));
    res = maFileWrite(file, data, sizeof(data));
    MAASSERT(res == 0);
    printf("Closing...\n");
    res = maFileClose(file);
    MAASSERT(res == 0);
    printf("Done.\n");
    return true;
}