コード例 #1
0
ファイル: main.cpp プロジェクト: AliSayed/MoSync
extern "C" int MAMain() {
	printf("Local time:\n");
	time_t myTime = maLocalTime();
	for(int i = 0; i < 366*8 ; i++){
		printf("%s\n", sprint_time(myTime));
		myTime -= (60 * 60 * 24);
	}
	FREEZE;
}
コード例 #2
0
void NewMenuScreen::mtxTagData(const char* data, int len) {
	if(!strcmp(parentTag.c_str(), "notedate")) {
		parentTag = "";
		notedate = data;
		tm t;
		t.tm_year = atoi(notedate.substr(0,4).c_str())-1900;
		t.tm_mon = atoi(notedate.substr(5,2).c_str())-1;
		t.tm_mday = atoi(notedate.substr(8,2).c_str());
		t.tm_hour = atoi(notedate.substr(11,2).c_str());
		t.tm_min = atoi(notedate.substr(14,2).c_str());
		t.tm_sec = atoi(notedate.substr(17,2).c_str());
		int ndate = mktime(&t);
		if(ndate > atoi(feed->getNoteSeconds().c_str())){
			feed->setNoteLoaded(true);
			int seconds = maLocalTime();
			int secondsLength = Util::intlen(seconds);
			char *secString = new char[secondsLength+1];
			memset(secString,'\0',secondsLength+1);
			sprintf(secString, "%d", seconds);
			feed->setNoteSeconds(secString);
			delete secString;
			secString = NULL;

			Util::saveData("fd.sav",feed->getAll().c_str());

			if(first==1){
				first = 0;
				feed->remHttp();

				if (shown) {
					if(next!=NULL){
						delete next;
						feed->remHttp();
						next = NULL;
					}
					/* Notifications */
					next = new DetailScreen(this, feed, DetailScreen::NOTIFICATIONS, NULL);
					next->show();
				}
			}
		}
	}
	else if (len > 0) {
		if(next!=NULL){
			//delete next;
		}
		String find = String(data);
		if (find.find("http://") == 0) {
			feed->remHttp();
			if (shown) {
				next = new NewVersionScreen(this, data, feed);
				next->show();
			}
		}
	}
}
コード例 #3
0
ファイル: DateTime.cpp プロジェクト: Felard/MoSync
	//-------------------------------------------------------------------------
	//
	// returns today's date in local time, as a DateTime.
	//
	DateTime DateTime::today( )
	//-------------------------------------------------------------------------
	{
		time_t now = maLocalTime( );
		tm tim;
		split_time( now, &tim );
		tim.tm_hour = 0;
		tim.tm_min = 0;
		tim.tm_sec = 0;
		return DateTime( mktime( &tim ) );
	}
コード例 #4
0
ファイル: Login.cpp プロジェクト: AirBayCreative/GameCards
void Login::mtxTagEnd(const char* name, int len) {
	if(!strcmp(name, "status")) {
		feed->setCredits(credits.c_str());
		feed->setPremium(premium.c_str());
		feed->setHandle(handle.c_str());
		feed->setEmail(email.c_str());
		feed->setUnsuccessful("Success");
		feed->setTouch(touch.c_str());
		feed->setFreebie(freebie.c_str());
		feed->setRegistered("1");
		int seconds = maLocalTime();
		int secondsLength = Util::intlen(seconds);
		char *secString = new char[secondsLength+1];
		memset(secString,'\0',secondsLength+1);
		sprintf(secString, "%d", seconds);
		feed->setSeconds(secString);
		delete secString;
		secString = NULL;
		username = "";
		error_msg= "";
		Util::saveData("fd.sav", feed->getAll().c_str());
		String albums = "";
		Util::getData("lb.sav", albums);
		feed->setAlbum(albums.c_str());
		albums = "";

		// Check result
		if (strcmp("0", freebie.c_str()) == 0) {
			origMenu = new NewMenuScreen(feed);
			next = new ShopCategoriesScreen(this, feed, ShopCategoriesScreen::ST_FREEBIE);
		} else {
			next = new NewMenuScreen(feed);
		}
		next->show();
	} else if(!strcmp(name, "error")) {
		error = true;
		feed->setUnsuccessful(error_msg.c_str());
		notice->setCaption(error_msg.c_str());
		error_msg="";
	} else if (!strcmp(name, "result")) {
		isBusy = false;
		error = true;
		notice->setCaption(result.c_str());
		result="";
	} else {
		if (!error) {
			if (notice != NULL) {
				notice->setCaption("");
			}
		}
	}
}
コード例 #5
0
/**
 * Notifies that the transaction has been successfully processed.
 * The user should receive the purchased product.
 * Platform: Android and iOS.
 * @param purchase The object that sent the event.
 */
void ApplicationController::requestCompleted(const Purchase& purchase)
{
	// Notify UI that a product was purchased.
	mMainScreen->productPurchased(purchase.getProductId());

	// Update DB.
	DatabaseProduct* dbProduct = new DatabaseProduct();
	dbProduct->setProductID(purchase.getProductId());
	int date = maLocalTime();
	dbProduct->setDate(date);
	mDatabase->addRow(*dbProduct);
	delete dbProduct;
	dbProduct = NULL;
}
コード例 #6
0
/**
 * Notifies that a purchase has been restored.
 * Platform: iOS and Android.
 * @param purchase The purchase that has been restored.
 */
void ApplicationController::purchaseRestored(Purchase& purchase)
{
	Purchase* restoredItem = new Purchase(purchase.getProductId(), this);
	mPurchases.add(restoredItem);
	mCurrentPurchase = mPurchases.size()-1;
	//restoredItem->addPurchaseListener(this);
	restoredItem->verifyReceipt();
//	mCurrentPurchase = mPurchase

	// Store the product in the repository.
	DatabaseProduct* dbProduct = new DatabaseProduct();
	dbProduct->setProductID(purchase.getProductId());
	int date = maLocalTime();
	dbProduct->setDate(date);
	mDatabase->addRow(*dbProduct);
	delete dbProduct;
	dbProduct = NULL;
	delete restoredItem;
	restoredItem = NULL;

	// Notify The UI.
	mMainScreen->productRestored(purchase.getProductId());
}
コード例 #7
0
void MenuScreen::keyPressEvent(int keyCode) {
	int total = listBox->getChildren().size();
	int select = listBox->getSelectedIndex();
	switch(keyCode) {
		case MAK_FIRE:
		case MAK_SOFTLEFT:
			int index = listBox->getSelectedIndex();
			if(index == OP_ALBUMS) {
				if(menu!=NULL){
					delete menu;
					feed->remHttp();
				}
				menu = new AlbumLoadScreen(this, feed, AlbumLoadScreen::ST_ALBUMS);
				menu->show();
			} else if(index == OP_SHOP) {
				if(menu!=NULL){
					delete menu;
				}
				menu = new ShopCategoriesScreen(this, feed, ShopCategoriesScreen::ST_SHOP);
				menu->show();
			} else if(index == OP_PROFILE) {
				if(menu!=NULL){
					delete menu;
				}
				menu = new DetailScreen(this, feed, DetailScreen::PROFILE, NULL);
				menu->show();
			} else if(index == OP_NOTIFICATIONS) {
				if(menu!=NULL){
					delete menu;
				}
				/* Notifications */
				menu = new DetailScreen(this, feed, DetailScreen::NOTIFICATIONS, NULL);
				menu->show();
			} else if(index == OP_FRIENDS) {
				if(menu!=NULL){
					delete menu;
				}
				/* Notifications */
				menu = new DetailScreen(this, feed, DetailScreen::FRIENDS, NULL);
				menu->show();
			} else if(index == OP_INVITEFRIENDS) {
				if(menu!=NULL){
					delete menu;
				}
				/*Invite Friend */
				menu = new TradeFriendDetailScreen(this, feed, NULL);
				menu->show();
			} else if (index == OP_LOGOUT) {
#if not defined(MA_PROF_STRING_PLATFORM_IPHONEOS)
				Albums *albums = feed->getAlbum();
				Vector<String> tmp = albums->getIDs();
				for (Vector<String>::iterator itr = tmp.begin(); itr != tmp.end(); itr++) {
					String s = itr->c_str();
					s+="-lst.sav";
					Util::saveData(s.c_str(),"");
				}
				feed->setAll("");
				feed->setRegistered("1");
				Util::saveData("fd.sav",feed->getAll().c_str());
				Util::saveData("lb.sav","");

				if (feed->getHttps() > 0) {
					label = (Label*) mainLayout->getChildren()[0]->getChildren()[1];
					label->setCaption("Please wait for all connections to finish before exiting. Try again in a few seconds.");
				} else {
					if(menu!=NULL){
						//delete menu;
					}
					maExit(0);
				}
#endif
			}
			break;
		case MAK_BACK:
		case MAK_SOFTRIGHT:
#if not defined(MA_PROF_STRING_PLATFORM_IPHONEOS)
			/*if (menu!=NULL) {
					delete menu;
			}*/
			int seconds = maLocalTime();
			int secondsLength = Util::intlen(seconds);
			char *secString = new char[secondsLength+1];
			memset(secString,'\0',secondsLength+1);
			sprintf(secString, "%d", seconds);
			feed->setSeconds(secString);
			Util::saveData("fd.sav", feed->getAll().c_str());

			if (feed->getHttps() > 0) {
				label = (Label*) mainLayout->getChildren()[0]->getChildren()[1];
				label->setCaption("Please wait for all connections to finish before exiting. Try again in a few seconds.");
			} else {
				maExit(0);
			}
#endif
			break;
		case MAK_DOWN:
			if (select == total-1) {
				listBox->setSelectedIndex(0);
			} else {
				listBox->selectNextItem();
			}
			break;
		case MAK_UP:
			if (select == 0) {
				listBox->setSelectedIndex(total-1);
			} else {
				listBox->selectPreviousItem();
			}
			break;
	}
}
コード例 #8
0
ファイル: time.cpp プロジェクト: AliSayed/MoSync
int localTime() {
	printf("Local time:\n");
	printf("%s\n", sprint_time(maLocalTime()));
	return 0;
}
コード例 #9
0
ファイル: DateTime.cpp プロジェクト: Felard/MoSync
	//-------------------------------------------------------------------------
	//
	// returns current local time as a DateTime.
	//
	DateTime DateTime::now( )
	//-------------------------------------------------------------------------
	{
		return DateTime( maLocalTime( ) );
	}
コード例 #10
0
ファイル: PhoneGapCapture.cpp プロジェクト: acekiller/MoSync
	/**
	 * Event handler for capture events
	 * @param event the event struct.
	 */
	void PhoneGapCapture::customEvent(const MAEvent &event)
	{
		char pathBuffer[1024];
		char messageBuffer[1024];

		if (event.type == EVENT_TYPE_CAPTURE)
		{
			MACaptureEventData eventData = event.captureData;

			switch (eventData.type)
			{
				case MA_CAPTURE_EVENT_TYPE_VIDEO:
					// Videos are already stored, we need the filepath
					maCaptureGetVideoPath(
						eventData.handle,
						pathBuffer,
						sizeof(pathBuffer));
					sprintf(
						messageBuffer,
						"{\"message\":[{\"fullPath\":\"%s\",\"name\":\"%s\"}]}",
						pathBuffer,
						FileNameFromPath(pathBuffer));
					mMessageHandler->callSuccess(
						mCaptureCallBack,
						PHONEGAP_CALLBACK_STATUS_OK,
						messageBuffer,
						false);
					maCaptureDestroyData(eventData.handle);
					break;

				case MA_CAPTURE_EVENT_TYPE_IMAGE:
				{
					char deviceOS[64];
					String extension;
					char localPath[1024];

					maGetSystemProperty(
						"mosync.device.OS",
						deviceOS,
						sizeof(deviceOS));

					// File format is different on different platforms.
					// TODO: What about WP?
					if (strcmp(deviceOS, "iPhone OS") == 0)
					{
						extension = "png";
					}
					else if(strcmp(deviceOS, "Android") == 0)
					{
						extension = "jpg";
					}
					else
					{
						// TODO: What to use as default?
						extension = "image";
					}

					// Images need to be stored. We use maLocalTime to
					// get a unique number for the filename.
					maGetSystemProperty(
						"mosync.path.local",
						localPath,
						sizeof(localPath));
					sprintf(
						pathBuffer,
						"%simg%d.%s",
						localPath,
						maLocalTime(),
						extension.c_str());
					int result = maCaptureWriteImage(
						eventData.handle,
						pathBuffer,
						sizeof(pathBuffer));
					sprintf(
						messageBuffer,
						"{\"message\":[{\"fullPath\":\"%s\",\"name\":\"%s\"}]}",
						pathBuffer,
						FileNameFromPath(pathBuffer));

					if (result == MA_CAPTURE_RES_OK)
					{
						mMessageHandler->callSuccess(
							mCaptureCallBack,
							PHONEGAP_CALLBACK_STATUS_OK,
							messageBuffer,
							false);
					}
					else
					{
						mMessageHandler->callError(
							mCaptureCallBack,
							PHONEGAP_CALLBACK_STATUS_ERROR,
							"{\"code\":\"CAPTURE_INTERNAL_ERR\"}",
							false);
					}

					// Free capture data.
					maCaptureDestroyData(eventData.handle);

					break;
				}

				case MA_CAPTURE_EVENT_TYPE_CANCEL:
					mMessageHandler->callError(
						mCaptureCallBack,
						PHONEGAP_CALLBACK_STATUS_ERROR,
						"{\"code\":\"CAPTURE_NO_MEDIA_FILES\"}",
						false);
					break;
			} // switch
		}
	}
コード例 #11
0
void NewMenuScreen::keyPressEvent(int keyCode) {
	switch(keyCode) {
		case MAK_FIRE:
		case MAK_SOFTLEFT:
			int index = menu->getSelectedKey();
			if(index == OP_ALBUMS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new AlbumLoadScreen(this, feed, AlbumLoadScreen::ST_ALBUMS);
				next->show();
				/*if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new TutorialScreen(this, tutItems, sizeof(tutItems)/sizeof(tutItem));
				next->show();*/
			} else if(index == OP_PLAY) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new OptionsScreen(feed, OptionsScreen::ST_PLAY_OPTIONS, this);
				next->show();
			} else if(index == OP_DECKS) {//decks
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new DeckListScreen(this, feed);
				next->show();
			} else if(index == OP_SHOP) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new ShopCategoriesScreen(this, feed, ShopCategoriesScreen::ST_SHOP);
				next->show();
			} else if(index == OP_AUCTIONS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new ShopCategoriesScreen(this, feed, ShopCategoriesScreen::ST_AUCTIONS);
				next->show();
			} else if(index == OP_CREDITS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new DetailScreen(this, feed, DetailScreen::BALANCE);
				next->show();
			} else if(index == OP_PROFILE) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new DetailScreen(this, feed, DetailScreen::PROFILE, NULL);
				next->show();
			} else if(index == OP_NOTIFICATIONS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				/* Notifications */
				next = new DetailScreen(this, feed, DetailScreen::NOTIFICATIONS, NULL);
				next->show();
			} else if(index == OP_RANKINGS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new ShopCategoriesScreen(this, feed, ShopCategoriesScreen::ST_RANKING);
				next->show();
			} else if(index == OP_FRIENDRANKS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new ShopCategoriesScreen(this, feed, ShopCategoriesScreen::ST_FRIEND);
				next->show();
			} else if(index == OP_FRIENDS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				/* Notifications */
				next = new DetailScreen(this, feed, DetailScreen::FRIENDS, NULL);
				next->show();
			} else if(index == OP_INVITEFRIENDS) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				/*Invite Friend */
				next = new TradeFriendDetailScreen(this, feed, NULL);
				next->show();
			} else if(index == OP_REDEEM) {
				if(next!=NULL){
					delete next;
					feed->remHttp();
					next = NULL;
				}
				next = new RedeemScreen(feed, this);
				next->show();
			} else if (index == OP_LOGOUT) {
#if not defined(MA_PROF_STRING_PLATFORM_IPHONEOS)
				Albums *albums = feed->getAlbum();
				Vector<String> tmp = albums->getIDs();
				for (Vector<String>::iterator itr = tmp.begin(); itr != tmp.end(); itr++) {
					String s = itr->c_str();
					s+="-lst.sav";
					Util::saveData(s.c_str(),"");
				}
				feed->setAll("");
				feed->setRegistered("1");
				Util::saveData("fd.sav",feed->getAll().c_str());
				Util::saveData("lb.sav","");

				if (feed->getHttps() > 0) {
					label = (Label*) mainLayout->getChildren()[0]->getChildren()[1];
					label->setCaption("Please wait for all connections to finish before exiting. Try again in a few seconds.");
				} else {
					if(next!=NULL){
						//delete next;
					}
					maExit(0);
				}
#endif
			}
			break;
		case MAK_BACK:
		case MAK_SOFTRIGHT:
#if not defined(MA_PROF_STRING_PLATFORM_IPHONEOS)
			/*if (next!=NULL) {
					delete next;
			}*/
			int seconds = maLocalTime();
			int secondsLength = Util::intlen(seconds);
			char *secString = new char[secondsLength+1];
			memset(secString,'\0',secondsLength+1);
			sprintf(secString, "%d", seconds);
			feed->setSeconds(secString);
			Util::saveData("fd.sav", feed->getAll().c_str());

			if (feed->getHttps() > 0) {
				label = (Label*) mainLayout->getChildren()[0]->getChildren()[1];
				label->setCaption("Please wait for all connections to finish before exiting. Try again in a few seconds.");
			} else {
				maExit(0);
			}
#endif
			break;
	}
}
コード例 #12
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 CreateNotificationScreen::buttonClicked(Widget* button)
{
	printf("CreateNotificationScreen::buttonClicked");
	if (button == mCreateNotificationButton)
	{
		if (!this->isUserInputDataValid())
		{
			return;
		}

		LocalNotification* notification = new LocalNotification();

		mLocalNotificationVector.add(notification);

		// Set fire date.
		String secondsString = mTime->getText();
		int seconds = MAUtil::stringToInteger(secondsString);
		int secondsLocalTime = maLocalTime();
		int scheduleTime = secondsLocalTime + seconds;
		tm fireDate;
		split_time(scheduleTime, &fireDate);
		notification->setFireDate(&fireDate);

		// Set content body
		MAUtil::String contentBody = mContentBody->getText();
		notification->setContentBody(contentBody);

		// Set play sound property
		bool playSound = mPlaySound->isChecked();
		notification->setPlaySound(playSound);

		if (isIOS())
		{
			// Set badge number
			MAUtil::String badgeNumberString = mBadgeNumber->getText();
			int badgeNumber = MAUtil::stringToInteger(badgeNumberString, 10);
			notification->setBadgeNumber(badgeNumber);

			// Set alert action.
			MAUtil::String alertAction = mAlertAction->getText();
			notification->setAlertAction(alertAction);
		}
		else
		{
			notification->setContentTitle(mContentTitle->getText());
			notification->setTickerText(mTickerText->getText());
			if ( mVibrate->isChecked() )
			{
				notification->setVibrate(true);
				if ( mVibrateDuration->getText().length() > 0 )
				{
					notification->setVibrateDuration(
							MAUtil::stringToInteger(mVibrateDuration->getText()));
				}
			}
			else
			{
				notification->setVibrate(false);
			}
			if ( mFlash->isChecked() )
			{
				// Check if flashing LED is possible on the device.
//				if ( MA_NOTIFICATION_RES_OK == notification->setFlashLights(true) )
				if ( notification->setFlashLights(true) )
				{
					mFlashColor->setText("IS available");
					if ( checkFlashPattern() )
					{
						struct NotificationFlashLights pattern = NotificationFlashLights(
									MAUtil::stringToInteger(mFlashColor->getText()),
									MAUtil::stringToInteger(mFlashOnLength->getText()),
									MAUtil::stringToInteger(mFlashOffLength->getText()));
						notification->setFlashLightsPattern(pattern);
					}
				}
				else
				{
						mFlashColor->setText("Not available");
						mFlashOffLength->setText("Not available");
						mFlashOnLength->setText("Not available");
						mFlashColor->setEnabled(false);
						mFlashOffLength->setEnabled(false);
						mFlashOnLength->setEnabled(false);
						mFlash->setState(false);
						mFlash->setEnabled(false);
				}
			}
			else
			{
				notification->setFlashLights(false);
			}
			if ( playSound )
			{
				notification->setSound(mSoundPath->getText());
			}
		}

//		notification->setFlag(NOTIFICATION_FLAG_AUTO_CANCEL);
		NotificationManager::getInstance()->scheduleLocalNotification(notification);
		printf("notification created with handle = %d ", notification->getHandle());
		this->resetView();
	}
}