Exemplo n.º 1
0
void
User::loadUser()
{
	AppRegistry* appRegistry = Application::GetInstance()->GetAppRegistry();
	User *user = currentUser();

	int id = 0;
	String fullname = "";
	String username = "";
	String email = "";

	appRegistry->Get(idKey, id);

	if (id != 0) {
		user->setId((unsigned)id);

		appRegistry->Get(fullnameKey, fullname);
		user->setFullname(fullname);

		appRegistry->Get(usernameKey, username);
		user->setUsername(username);

		appRegistry->Get(emailKey, email);
		user->setEmail(email);
	}
}
Exemplo n.º 2
0
void
User::saveUser()
{
	AppRegistry* appRegistry = Application::GetInstance()->GetAppRegistry();
	User *user = currentUser();

	// First time saving
	int i = 0;
	result r = appRegistry->Get(idKey, i);
	if (r == E_KEY_NOT_FOUND) {
		appRegistry->Add(idKey, 0);
		appRegistry->Add(fullnameKey, "");
		appRegistry->Add(usernameKey, "");
		appRegistry->Add(emailKey, "");
		appRegistry->Save();
	}

	if (user->id() != 0) {
		appRegistry->Set(idKey, (signed)user->id());
		appRegistry->Set(fullnameKey, user->fullname());
		appRegistry->Set(usernameKey, user->username());
		appRegistry->Set(emailKey, user->email());
	} else {
		appRegistry->Set(idKey, 0);
		appRegistry->Set(fullnameKey, "");
		appRegistry->Set(usernameKey, "");
		appRegistry->Set(emailKey, "");
	}

	appRegistry->Save();
}
Exemplo n.º 3
0
void
ImageViewer::SaveImage(void)
{
	if(savedPath.GetLength() != 0)
		return;						/*Already saved*/

	result res = E_SUCCESS;
	Image img;
	String fileName;
	int lastFileName = 0;
	String fileNameKey("AppLastSavedFileNum");
	AppRegistry *pAppRegistry = Application::GetInstance()->GetAppRegistry();

	res = pAppRegistry->Get(fileNameKey, lastFileName);
	if ( res == E_KEY_NOT_FOUND)
	{
		lastFileName = 1;
		pAppRegistry->Add(fileNameKey, lastFileName);
	}

	savedPath = L"/Media/Images/";
	savedPath += Application::GetInstance()->GetAppName();
	savedPath.Append(lastFileName);
	savedPath += ".jpg";

	img.Construct();
	res = img.EncodeToFile(*__pDisplayImage, IMG_FORMAT_JPG, savedPath, true);

	pAppRegistry->Set(fileNameKey, lastFileName + 1);

}