/**
 * 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::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);
}
/**
 * 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::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);
}
/**
 * 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);
}
/**
 * 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);
}
Beispiel #7
0
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");
}
Beispiel #8
0
/**
 * 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;
}
Beispiel #9
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;
}
/**
 * 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);
}
/**
 * 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);
}
Beispiel #12
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;
}