예제 #1
0
void TriangleStripVBO::initVBO(const MAUtil::Vector<TriangleStrip>& strips) {

	/**/ // VBO code
	glGenBuffers(1, &mVBO);
	glBindBuffer(GL_ARRAY_BUFFER, mVBO);

	int totalDataSize = 0;
	int vertexCoordOffset = 0;
	int textureCoordOffset = 0;
	mTriangleStrips.clear();

	for(int i = 0; i < strips.size(); i++)
	{
		textureCoordOffset = vertexCoordOffset + strips[i].vertices.size()*sizeof(vec3);
		mTriangleStrips.add(TriangleStripInfo(vertexCoordOffset, textureCoordOffset, strips[i].vertices.size()));
		vertexCoordOffset = textureCoordOffset + strips[i].textureCoordinates.size()*sizeof(vec2);
	}

	totalDataSize = vertexCoordOffset;

	glBufferData(GL_ARRAY_BUFFER, totalDataSize, NULL, GL_STATIC_DRAW);

	for(int i = 0; i < strips.size(); i++)
	{
		glBufferSubData(GL_ARRAY_BUFFER, mTriangleStrips[i].vertexCoordOffset, mTriangleStrips[i].numVertices*sizeof(vec3), &strips[i].vertices[0]);
		glBufferSubData(GL_ARRAY_BUFFER, mTriangleStrips[i].textureCoordOffset, mTriangleStrips[i].numVertices*sizeof(vec2), &strips[i].textureCoordinates[0]);
	}

	glBindBuffer(GL_ARRAY_BUFFER, 0);
}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addNotesButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	OpenMenuCommand *notesButtonCmd = new OpenMenuCommand(menu);

	/**
	 * We only want to retrieve from Facebook the "id", "subject" and "from" fields from an Album object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("id");
	fields.add("subject");
//	fields.add("from");
	ConnectionRequestCommand *displayNotesCmd = new ConnectionRequestCommand( mFacebookManager,
			notesButtonCmd->getMenuScreen(),
			Connections<User>::notes(), fields, "me");
	ListItem *displayNotes = new ListItem(displayNotesCmd, "Display notes");
	notesButtonCmd->addMenuItem(displayNotes);

	//create new friend list
	AddCommand<Note> *createNoteCmd = new AddCommand<Note>( mFacebookManager,
			notesButtonCmd->getMenuScreen());
	createNoteCmd->setNoteParams("New note created with MOSYNC_SDK", "Testing creating a note with Facebook library");
	ListItem *createNote = new ListItem(createNoteCmd, "Create Note");
	notesButtonCmd->addMenuItem(createNote);

	ListItem *listsButton = new ListItem(notesButtonCmd, "notes");
	menu->add(listsButton);
}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addCheckinsButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	OpenMenuCommand *checkinsButtonCmd = new OpenMenuCommand(menu);

	/**
	 * We only want to retrieve from Facebook the "place" and "id" fields from an Checkin object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("id");
	fields.add("place");
	//fields.add("application");
	ConnectionRequestCommand *displayCheckinsCmd = new ConnectionRequestCommand( mFacebookManager,
			checkinsButtonCmd->getMenuScreen(), Connections<User>::checkins(), fields, "me");

	ListItem *displayCheckins = new ListItem(displayCheckinsCmd, "display checkins");
	checkinsButtonCmd->addMenuItem(displayCheckins);

	//create new checkin
	AddCommand<Checkin> *createCheckinCmd = new AddCommand<Checkin>( mFacebookManager,
			checkinsButtonCmd->getMenuScreen());
	MAUtil::String placeIdMoSync = "126381597427662";
	Coordinate coordMoSync;
	coordMoSync.mLatitude = "59.339451";
	coordMoSync.mLongitude = "18.05798";
	createCheckinCmd->setCheckinParams(placeIdMoSync, coordMoSync);

	ListItem *createCheckin = new ListItem(createCheckinCmd, "create checkin");
	checkinsButtonCmd->addMenuItem(createCheckin);

	ListItem *checkinsButton = new ListItem(checkinsButtonCmd, "checkins");
	menu->add(checkinsButton);
}
예제 #4
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;
	}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addStatusMessagesButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	OpenMenuCommand *statusButtonCmd = new OpenMenuCommand(menu);

	/**
	 * We only want to retrieve from Facebook the "name", "id", "message" fields from an StatusMessage object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("id");
	fields.add("message");
	ConnectionRequestCommand *displayStatusesCmd = new ConnectionRequestCommand( mFacebookManager,
			menu, Connections<User>::statuses(), fields, "me");
	ListItem *displayStatuses = new ListItem(displayStatusesCmd, "Display status messages");
	statusButtonCmd->addMenuItem(displayStatuses);

	//create new status message
	AddCommand<StatusMessage> *createStatusMsgCmd = new AddCommand<StatusMessage>( mFacebookManager, menu);
	createStatusMsgCmd->setMessage("New status message created with MOSYNC_SDK");
	ListItem *createStatusMsg = new ListItem(createStatusMsgCmd, "Create StatusMessage");
	statusButtonCmd->addMenuItem(createStatusMsg);

	ListItem *statusButton = new ListItem(statusButtonCmd, "status messages");
	menu->add(statusButton);
}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addAlbumsButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	OpenMenuCommand *albumsButtonCmd = new OpenMenuCommand(menu);

	/**
	 * We only want to retrieve from Facebook the "name", "id", "description" and "count" fields from an Album object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("name");
	fields.add("id");
//	fields.add("description");
//	fields.add("count");
	ConnectionRequestCommand *displayAlbumsCmd = new ConnectionRequestCommand(  mFacebookManager,
			albumsButtonCmd->getMenuScreen(),
			Connections<User>::albums(), fields, "me");

	ListItem *displayAlbums = new ListItem(displayAlbumsCmd, "display albums");
	albumsButtonCmd->addMenuItem(displayAlbums);

	//create new album
	AddCommand<Album> *createAlbumCmd = new AddCommand<Album>( mFacebookManager,
			albumsButtonCmd->getMenuScreen());
	createAlbumCmd->setAlbumName("New album created with MOSYNC_SDK");

	ListItem *createAlbum = new ListItem(createAlbumCmd, "create album");
	albumsButtonCmd->addMenuItem(createAlbum);

	ListItem *albumsButton = new ListItem(albumsButtonCmd, "albums");
	menu->add(albumsButton);
}
예제 #7
0
파일: main.cpp 프로젝트: Felard/MoSync
void testConnectOverload(const char* url, bool acceptSuccess) {
	int connects = 0, events = 0;
	int result = 0;
	int conn;
	bool hasConn = false;
	MAUtil::Vector<Handle> conns;
	do {
		EVENT event;
		while(maGetEvent(&event)) {
			if(event.type == EVENT_TYPE_CLOSE ||
				(event.type == EVENT_TYPE_KEY_PRESSED && event.key == MAK_0))
			{
				maExit(0);
			} else if(event.type == EVENT_TYPE_CONN) {
				printf("Op %i conn %i result %i\n", event.conn.opType, event.conn.handle, event.conn.result);
				MAASSERT(event.conn.opType == CONNOP_CONNECT);
				conn = event.conn.handle;
				if(acceptSuccess) {
					if(event.conn.result < 0) {
						result = event.conn.result;
					}
				} else {
					result = event.conn.result;
				}
				MAASSERT(event.conn.result != 0);
				hasConn = true;
				events++;
				printf("Event %i\n", events);
				break;
			}
		}
		if(result == 0) {
			conn = maConnect(url);
			conns.add(conn);
			if(conn < 0) {
				printf("maConnect error %i\n", conn);
				result = conn;
				hasConn = false;
			} else {
				connects++;
				printf("Connect %i\n", connects);
			}
		} else if(events != connects)
			maWait(0);
	} while(events != connects);// && connects < 3);
	if(hasConn) {
		printf("Result %i on handle %i after %i connects\n", result, conn, connects);
	} else {
		printf("Result %i after %i connects\n", result, connects);
	}
	printf("Closing %i handles\n", conns.size());
	for(int i=0; i<conns.size(); i++) {
		maConnClose(conns[i]);
	}
	printf("Done.\n");
}
예제 #8
0
/**
 * Provides the titles.
 * Only for the checked ones.
 */
MAUtil::Vector<MAUtil::String> MediaWiki::getAllCheckedTitles()
{
	MAUtil::Vector<MAUtil::String> list;
	for (int i=0; i < mWiki->titleResults.size(); i++)
	{
		if ( !isItemHidden(i) )
		{
			list.add(mWiki->titleResults[i]);
		}
	}
	return list;
}
예제 #9
0
	// Helper function for removing an entry from the expected list.
	void eraseExpected(
		MAUtil::Vector<MAUtil::String>& v,
		const MAUtil::String& s)
	{
		for (int i = 0; i < v.size(); ++i)
		{
			if (v[i] == s)
			{
				v.remove(i);
				return;
			}
		}
	}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addLinksButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	MAUtil::Vector<MAUtil::String> fields;
	fields.add("id");
	fields.add("name");
//	fields.add("message");
	ConnectionRequestCommand *displayLinksCmd = new ConnectionRequestCommand( mFacebookManager, menu,
			Connections<User>::links(), fields, "me");

	ListItem *button = new ListItem(displayLinksCmd, "links");
	menu->add(button);
}
예제 #11
0
/**
 * Post an HTTP request.
 *
 * The HTTP header parameters must be a vector (possibly empty)
 * of strings, ordered as key/value pairs.
 *
 * @param url The url of the POST request.
 * @param httpParams HTTP header parameters.
 * @param requestBody Data written to the request body.
 * @param requestLength Length of the request body.
 *
 * @return WORMHOLE_HTTP_SUCCESS if successful, WORMHOLE_HTTP_ERROR on error.
 */
int HighLevelHttpConnection::postRequest(
    const char* url,
    MAUtil::Vector<MAUtil::String>& httpParams,
    const void* requestBody,
    int requestLength)
{
    // Create request.
    int result = create(url, HTTP_POST);
    if (result < 0)
    {
        return WORMHOLE_HTTP_ERROR;
    }

    // Write headers.
    for (int i = 0; i < httpParams.size(); i = i + 2)
    {
        setRequestHeader(
            httpParams[i].c_str(),
            httpParams[i + 1].c_str());
    }

    // Write request data.
    write(requestBody, requestLength);

    // Next that happens is that connWriteFinished is called.

    return WORMHOLE_HTTP_SUCCESS;
}
예제 #12
0
파일: Video.cpp 프로젝트: jaumem/MoSync
void Video::setComments(const MAUtil::Vector<Comment> &comments)
{
	mComments.clear();
	for(int i=0; i<comments.size(); i++)
	{
		mComments.add(comments[i]);
	}
}
예제 #13
0
파일: Video.cpp 프로젝트: jaumem/MoSync
void Video::setTags(MAUtil::Vector<IdNamePair> &tags)
{
	mTags.clear();
	for(int i=0; i<tags.size(); i++)
	{
		mTags.add(tags[i]);
	}
}
예제 #14
0
/**
 * Provides the snippets along with the title.
 * Only for the checked ones.
 */
MAUtil::Vector<MAUtil::String> MediaWiki::getAllSnippetsWithTitle()
{
	MAUtil::Vector<MAUtil::String> list;
	for (int i=0; i < mWiki->titleResults.size(); i++)
	{
		if ( !isItemHidden(i) )
		{
			// Each entry has title and the corresponding snippet.
			MAUtil::String line =
				mWiki->titleResults[i] +
				"\n" +
				mWiki->snippetResults[i] ;
			list.add(line);
		}
	}
	return list;
}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addPhotosButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	/**
	 * We only want to retrieve from Facebook the "from", "name" and "id" fields from an Photo object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("from");
//	fields.add("name");
	fields.add("id");
	ConnectionRequestCommand *displayPhotosCmd = new ConnectionRequestCommand( mFacebookManager, menu,
			Connections<User>::photos(), fields, "me");

	ListItem *button = new ListItem(displayPhotosCmd, "photos");
	menu->add(button);
}
예제 #16
0
파일: Map.cpp 프로젝트: ronald132/MoSync
/**
 * Gets the current map visible area.
 * @return A vector containing two location points: the upper left corner and the lower right corner if
 * the value from the runtime is corrent and NULL otherwise.
 */
MAUtil::Vector<Location> Map::getVisibleArea()
{
    MAUtil::Vector<Location> corners;

    MAUtil::String upperLeftCornerLatitude = this->getPropertyString(MAW_MAP_VISIBLE_AREA_UPPER_LEFT_CORNER_LATITUDE);
    MAUtil::String upperLeftCornerLongitude = this->getPropertyString(MAW_MAP_VISIBLE_AREA_UPPER_LEFT_CORNER_LONGITUDE);
    MAUtil::String lowerRightCornerLatitude = this->getPropertyString(MAW_MAP_VISIBLE_AREA_LOWER_RIGHT_CORNER_LATITUDE);
    MAUtil::String lowerRightCornerLongitude = this->getPropertyString(MAW_MAP_VISIBLE_AREA_LOWER_RIGHT_CORNER_LONGITUDE);

    Location upperLeftCorner, lowerRightCorner;

    upperLeftCorner.setLatitude(MAUtil::stringToDouble(upperLeftCornerLatitude));
    upperLeftCorner.setLongitude(MAUtil::stringToDouble(upperLeftCornerLongitude));
    lowerRightCorner.setLatitude(MAUtil::stringToDouble(lowerRightCornerLatitude));
    lowerRightCorner.setLongitude(MAUtil::stringToDouble(lowerRightCornerLongitude));
    corners.add(upperLeftCorner);
    corners.add(lowerRightCorner);

    return corners;
}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addEventsButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	OpenMenuCommand *eventsButtonCmd = new OpenMenuCommand(menu);

	/**
	 * We only want to retrieve from Facebook the "name", "id", "name" and "start_time" and "location" fields from an Event object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("id");
	fields.add("name");
//	fields.add("start_time");
	fields.add("location");
	ConnectionRequestCommand *displayEventsCmd = new ConnectionRequestCommand( mFacebookManager,
			eventsButtonCmd->getMenuScreen(), Connections<User>::events(), fields, "me");

	ListItem *displayEvents = new ListItem(displayEventsCmd, "Display events");
	eventsButtonCmd->addMenuItem(displayEvents);

	//create new event
	AddCommand<Event> *createEventCmd = new AddCommand<Event>( mFacebookManager,
			eventsButtonCmd->getMenuScreen());

	//event
	UnixTimeStamp startTimeStamp(Date("2012", "10", "6"), Time("4","15","30"));
	UnixTimeStamp endTimeStamp(Date("2012", "10", "6"), Time("5", "20","00"));

	createEventCmd->setEventParams("New event created with MOSYNC_SDK", startTimeStamp, endTimeStamp,
			"Testing creating an event", "Stockholm");

	ListItem *createEvent = new ListItem(createEventCmd, "Create event");
	eventsButtonCmd->addMenuItem(createEvent);

	ListItem *eventsButton = new ListItem(eventsButtonCmd, "events");
	menu->add(eventsButton);
}
예제 #18
0
/**
 * Delete the entries on selected indexes.
 * @param indexList The list with the indexes of the records that
 * need to be deleted.
 */
void MediaWiki::filterData(MAUtil::Vector<int> indexList)
{

	int shift = 0;
	// The vector is shifted to the left.
	for (int i=0; i < indexList.size(); i++)
	{
		if ( indexList[i]-shift >= 0)
		{
			if ( indexList[i]-shift < mWiki->titleResults.size() ){
				mWiki->titleResults.remove(indexList[i]-shift);
			}
			if ( indexList[i]-shift < mWiki->snippetResults.size() ){
				mWiki->snippetResults.remove(indexList[i]-shift);
			}
		}
		shift++;
	}
}
/**
 * Creates a button and adds it to the main menu
 * Adds on the button a command that sends the connection request to Facebook
 */
void FacebookDemoMoblet::addHomeButton(FacebookDemoGUI::FacebookDemoScreen *menu)
{
	using namespace FacebookDemoGUI;
	using namespace FacebookDemoApplication;

	/**
	 * We only want to retrieve from Facebook the "id", "name", and "caption"  fields from an Album object
	 */
	MAUtil::Vector<MAUtil::String> fields;
	fields.add("id");
	fields.add("from");
	fields.add("name");
//	fields.add("caption");
	fields.add("message");
	fields.add("application");
	fields.add("type");
	ConnectionRequestCommand *displayHomeCmd = new ConnectionRequestCommand( mFacebookManager, menu,
			Connections<User>::home(), fields, "me");

	ListItem *homeButton = new ListItem(displayHomeCmd, "home");
	menu->add(homeButton);
}