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); }
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(); }