//--------------------------------------------------------------------- void __fastcall TPlayDlgBox::TimerTimer(TObject *Sender) { UpdateItem(); }
void MimeTypeListView::MessageReceived(BMessage* message) { switch (message->what) { case B_META_MIME_CHANGED: { const char* type; int32 which; if (message->FindString("be:type", &type) != B_OK || message->FindInt32("be:which", &which) != B_OK) break; switch (which) { case B_SHORT_DESCRIPTION_CHANGED: { // update label MimeTypeItem* item = FindItem(type); if (item != NULL) UpdateItem(item); break; } case B_MIME_TYPE_CREATED: { // delay creation of new item a bit, until the type is fully installed BMessage addType(kMsgAddType); addType.AddString("type", type); if (BMessageRunner::StartSending(this, &addType, 200000ULL, 1) != B_OK) { _AddNewType(type); } break; } case B_MIME_TYPE_DELETED: { // delete item MimeTypeItem* item = FindItem(type); if (item != NULL) { RemoveItem(item); delete item; } break; } case B_PREFERRED_APP_CHANGED: { // try to add or remove this type (changing the preferred // app might change visibility in our list) _AddNewType(type); // supposed to fall through } case B_ICON_CHANGED: // TODO: take B_ICON_FOR_TYPE_CHANGED into account, too { MimeTypeItem* item = FindItem(type); if (item != NULL && fShowIcons) { // refresh item InvalidateItem(IndexOf(item)); } break; } default: break; } break; } case kMsgAddType: { const char* type; if (message->FindString("type", &type) == B_OK) _AddNewType(type); break; } default: BOutlineListView::MessageReceived(message); } }
bool psSlotManager::HandleEvent( iEvent& ev ) { if(isDragging) { int button = csMouseEventHelper::GetButton(&ev); if(ev.Name == MouseMove) { if(isPlacing) { // Update item position. UpdateItem(); } } else if(ev.Name == MouseDown) { if(button == csmbLeft) // Left { if(isPlacing) { // Drop the item at the current position. DropItem(!(csMouseEventHelper::GetModifiers(&ev) & CSMASK_SHIFT)); return true; } else { PlaceItem(); } } else if(button == csmbRight) // right { if(!isRotating) { basePoint = PawsManager::GetSingleton().GetMouse()->GetPosition(); isRotating = true; if(csMouseEventHelper::GetModifiers(&ev) & CSMASK_SHIFT) { psengine->GetSceneManipulator()->SetRotation(PS_MANIPULATE_PITCH,PS_MANIPULATE_YAW); } else { psengine->GetSceneManipulator()->SetRotation(PS_MANIPULATE_ROLL,PS_MANIPULATE_NONE); } return true; } } else { CancelDrag(); } } else if(ev.Name == MouseUp) { if(button == csmbRight) // right { if(isRotating) { //PawsManager::GetSingleton().GetMouse()->SetPosition(basePoint.x, basePoint.y); psengine->GetG2D()->SetMousePosition(basePoint.x, basePoint.y); psengine->GetSceneManipulator()->SetPosition(csVector2(basePoint.x, basePoint.y)); isRotating = false; return true; } } } /*else if(ev.Name == KeyDown) { } else if(ev.Name == KeyUp) { }*/ } return false; }
LRESULT CSideBar::OnMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_CREATE: { InitializeUI(); LPCREATESTRUCT pcs=reinterpret_cast<LPCREATESTRUCT>(lParam); m_Tooltip.Create(hwnd); m_Tooltip.Enable(m_fShowTooltips); SetTooltipFont(); for (int i=0;i<(int)m_ItemList.size();i++) { if (m_ItemList[i].Command!=ITEM_SEPARATOR) { RECT rc; GetItemRect(i,&rc); m_Tooltip.AddTool(i,rc); } } m_HotItem=-1; m_MouseLeaveTrack.Initialize(hwnd); } return 0; case WM_SIZE: if (m_HotItem>=0) { UpdateItem(m_HotItem); m_HotItem=-1; } UpdateTooltipsRect(); return 0; case WM_PAINT: { PAINTSTRUCT ps; ::BeginPaint(hwnd,&ps); Draw(ps.hdc,ps.rcPaint); ::EndPaint(hwnd,&ps); } return 0; case WM_MOUSEMOVE: { int x=GET_X_LPARAM(lParam),y=GET_Y_LPARAM(lParam); int HotItem=HitTest(x,y); if (HotItem>=0 && (m_ItemList[HotItem].Command==ITEM_SEPARATOR || m_ItemList[HotItem].IsDisabled())) HotItem=-1; if (GetCapture()==hwnd) { if (HotItem!=m_ClickItem) HotItem=-1; if (HotItem!=m_HotItem) { int OldHotItem; OldHotItem=m_HotItem; m_HotItem=HotItem; if (OldHotItem>=0) UpdateItem(OldHotItem); if (m_HotItem>=0) UpdateItem(m_HotItem); } } else { if (HotItem!=m_HotItem) { int OldHotItem; OldHotItem=m_HotItem; m_HotItem=HotItem; if (OldHotItem>=0) UpdateItem(OldHotItem); if (m_HotItem>=0) UpdateItem(m_HotItem); } m_MouseLeaveTrack.OnMouseMove(); } } return 0; case WM_MOUSELEAVE: if (m_HotItem>=0) { UpdateItem(m_HotItem); m_HotItem=-1; } if (m_MouseLeaveTrack.OnMouseLeave()) { if (m_pEventHandler) m_pEventHandler->OnMouseLeave(); } return 0; case WM_NCMOUSEMOVE: m_MouseLeaveTrack.OnNcMouseMove(); return 0; case WM_NCMOUSELEAVE: if (m_MouseLeaveTrack.OnNcMouseLeave()) { if (m_pEventHandler) m_pEventHandler->OnMouseLeave(); } return 0; case WM_LBUTTONDOWN: if (m_HotItem>=0) { m_ClickItem=m_HotItem; ::SetCapture(hwnd); } return 0; case WM_LBUTTONUP: if (::GetCapture()==hwnd) { ::ReleaseCapture(); if (m_HotItem>=0) { if (m_pEventHandler!=NULL) m_pEventHandler->OnCommand(m_ItemList[m_HotItem].Command); } } return 0; case WM_RBUTTONUP: if (m_pEventHandler!=NULL) m_pEventHandler->OnRButtonUp(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)); return 0; case WM_SETCURSOR: if (LOWORD(lParam)==HTCLIENT) { if (m_HotItem>=0) { ::SetCursor(GetActionCursor()); return TRUE; } } break; case WM_NOTIFY: switch (reinterpret_cast<NMHDR*>(lParam)->code) { case TTN_NEEDTEXT: { LPNMTTDISPINFO pnmttdi=reinterpret_cast<LPNMTTDISPINFO>(lParam); if (m_pEventHandler==NULL || !m_pEventHandler->GetTooltipText( m_ItemList[pnmttdi->hdr.idFrom].Command, pnmttdi->szText,lengthof(pnmttdi->szText))) { m_pCommandList->GetCommandShortNameByID( m_ItemList[pnmttdi->hdr.idFrom].Command, pnmttdi->szText,lengthof(pnmttdi->szText)); } pnmttdi->lpszText=pnmttdi->szText; pnmttdi->hinst=NULL; } return 0; case TTN_SHOW: if (m_fVertical) { LPNMHDR pnmh=reinterpret_cast<LPNMHDR>(lParam); RECT rcBar,rcTip; int x,y; ::GetWindowRect(hwnd,&rcBar); TVTest::Theme::BorderStyle Border=m_Theme.Border; ConvertBorderWidthsInPixels(&Border); TVTest::Theme::SubtractBorderRect(Border,&rcBar); ::GetWindowRect(pnmh->hwndFrom,&rcTip); x=rcBar.right; y=rcTip.top; HMONITOR hMonitor=::MonitorFromRect(&rcTip,MONITOR_DEFAULTTONULL); if (hMonitor!=NULL) { MONITORINFO mi; mi.cbSize=sizeof(mi); if (::GetMonitorInfo(hMonitor,&mi)) { if (x>=mi.rcMonitor.right-16) x=rcBar.left-(rcTip.right-rcTip.left); } } ::SetWindowPos(pnmh->hwndFrom,HWND_TOPMOST, x,y,rcTip.right-rcTip.left,rcTip.bottom-rcTip.top, SWP_NOACTIVATE); return TRUE; } break; } break; case WM_DESTROY: m_Tooltip.Destroy(); m_TooltipFont.Destroy(); return 0; } return CCustomWindow::OnMessage(hwnd,uMsg,wParam,lParam); }
void CCreateNewDatabase::AddFolder(SallyAPI::Database::CDatabaseConnection* dbconn, std::string& folder, const std::string& mediaDirectory) { HANDLE hFile; WIN32_FIND_DATA FileInformation; std::string firstFile; folder = SallyAPI::String::PathHelper::CorrectPath(folder); firstFile.append(folder); firstFile.append("*"); hFile = FindFirstFile(firstFile.c_str(), &FileInformation); if(hFile != INVALID_HANDLE_VALUE) { do { if ((strcmp(FileInformation.cFileName, ".") != NULL) && (strcmp(FileInformation.cFileName, "..") != NULL)) { std::string filename; filename.append(folder); filename.append(FileInformation.cFileName); if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { AddFolder(dbconn, filename, mediaDirectory); } else if (CAudioFile::IsAudioFile(filename) || CVideoFile::IsVideoFile(filename)) { // compare the last file write time with the lastRun time FILETIME writeTimeTemp = FileInformation.ftLastWriteTime; FILETIME creationTimeTemp = FileInformation.ftCreationTime; FILETIME writeTime; FILETIME creationTime; FileTimeToLocalFileTime(&writeTimeTemp, &writeTime); FileTimeToLocalFileTime(&creationTimeTemp, &creationTime); // get file Infos std::string sDBFileName = SallyAPI::String::StringHelper::ReplaceString(filename, "'", "#"); if ((CompareFileTime(&m_ftLastRun, &writeTime) <= 0) || (CompareFileTime(&m_ftLastRun, &creationTime) <= 0)) { SYSTEMTIME creationTimeSystem; FileTimeToSystemTime(&creationTime, &creationTimeSystem); std::string sDBFileCreated = SallyAPI::Date::DateHelper::GetDateString(creationTimeSystem, false); // check if it exists in the database std::string queryFind; queryFind.append("SELECT Filename FROM media WHERE UPPER(Filename) = UPPER('"); queryFind.append(sDBFileName); queryFind.append("');"); dbconn->LockDatabase(); SallyAPI::Database::CStatement* stmtFind = dbconn->CreateStatement(); bool found = false; try { SallyAPI::Database::CResultSet* rslt = stmtFind->ExecuteQuery(queryFind.c_str()); found = rslt->Next(); } catch (SallyAPI::Database::CSQLException* e) { SallyAPI::System::CLogger* logger = SallyAPI::Core::CGame::GetLogger(); logger->Error(e->GetMessage()); } dbconn->ReleaseDatabase(); if (found) { UpdateItem(filename, sDBFileName, sDBFileCreated); if (m_iUpdateItem == 15) { ExecuteUpdateItem(dbconn); } } else { CreateItem(filename, sDBFileName, sDBFileCreated); if (m_iCreateItem == 15) { ExecuteCreateItem(dbconn); } } } else { NoItemUpdate(sDBFileName); if (m_iNoUpdateItem == 15) { ExecuteNoUpdateItem(dbconn); } } // update processbar m_pProcessbar->SetPosition(m_pProcessbar->GetPosition() + 1); } } } while ((FindNextFile(hFile, &FileInformation) == TRUE) && (m_bPleaseStop == false)); } FindClose(hFile); return; }
void runlogic() { NSDL2_RUNLOGIC(NULL, NULL, "Executing init_script()"); init_script(); NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - Start"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Home"); Home(); NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - ProductAdddedBlock"); { int ProductAdddedBlockpercent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - ProductAdddedBlock = %d", ProductAdddedBlockpercent); if(ProductAdddedBlockpercent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - BrowseBlock (pct value = 0%)"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Browse"); Browse(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - ViewProductDetail"); ViewProductDetail(); NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - Block1 (pct value = 0%)"); { int Block1percent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - Block1 = %d", Block1percent); if(Block1percent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(Block1percent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - AddToBag (pct value = 100%)"); AddToBag(); } } } } else if(ProductAdddedBlockpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - SearchKeywordBlock (pct value = 100%)"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - SearchKeyword"); SearchKeyword(); NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - ProductSelection (pct value = 100%)"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - ProductSelectionStart"); ProductSelectionStart(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - RefineSearch"); RefineSearch(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - PerformPagination"); PerformPagination(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - SortProducts"); SortProducts(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - ChangeView"); ChangeView(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - ProductSelectionEnd"); ProductSelectionEnd(); } NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - Block2 (pct value = 100%)"); { int Block2percent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - Block2 = %d", Block2percent); if(Block2percent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(Block2percent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - ViewProductDetail (pct value = 100%)"); ViewProductDetail(); } } NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - Block2A (pct value = 100%)"); { int Block2Apercent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - Block2A = %d", Block2Apercent); if(Block2Apercent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(Block2Apercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - AddToBag (pct value = 100%)"); AddToBag(); } } } } else if(ProductAdddedBlockpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - SearchPIDBlock (pct value = 0%)"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - SearchProductId"); SearchProductId(); NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - Block3 (pct value = 0%)"); { int Block3percent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - Block3 = %d", Block3percent); if(Block3percent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(Block3percent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - AddToBag (pct value = 100%)"); AddToBag(); } else if(Block3percent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - Block3A (pct value = 0%)"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Browse"); Browse(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - ViewProductDetail"); ViewProductDetail(); NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - Block3B (pct value = 0%)"); { int Block3Bpercent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - Block3B = %d", Block3Bpercent); if(Block3Bpercent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(Block3Bpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - AddToBag (pct value = 100%)"); AddToBag(); } } } } } } } } NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - CheckOutBlock"); { int CheckOutBlockpercent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - CheckOutBlock = %d", CheckOutBlockpercent); if(CheckOutBlockpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - CheckOut (pct value = 100%)"); CheckOut(); } else if(CheckOutBlockpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(CheckOutBlockpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing sequence block - EditandCheckOutBlock (pct value = 0%)"); { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - UpdateItem"); UpdateItem(); NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - CheckOut"); CheckOut(); } } } NSDL2_RUNLOGIC(NULL, NULL, "Executing percent block - PlaceOrderBlock"); { int PlaceOrderBlockpercent = ns_get_random_number_int(1, 100); NSDL2_RUNLOGIC(NULL, NULL, "Percentage random number for block - PlaceOrderBlock = %d", PlaceOrderBlockpercent); if(PlaceOrderBlockpercent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - Abandonment (pct value = 0%)"); Abandonment(); } else if(PlaceOrderBlockpercent <= 0) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - RegCheckOut (pct value = 0%)"); RegCheckOut(); } else if(PlaceOrderBlockpercent <= 100) { NSDL2_RUNLOGIC(NULL, NULL, "Executing flow - UnRegCheckOut (pct value = 100%)"); UnRegCheckOut(); } } } NSDL2_RUNLOGIC(NULL, NULL, "Executing ns_exit_session()"); ns_exit_session(); }
/************************************************************************** * Function: BringUpNetwork * Functionality: start the network. * @IN :zDB: the database handle IPConfig : the struct contain the ip address needed by setup network NETWORK: render start wired or wifi network. * @OUT: 0 OK else error * Used description: start the wifi or wired network * Date: 20080117 * Changed history: * Date Who Reason * 20080117 sandy First creation ***************************************************************************/ int BringUpNetwork(PZDB_HANDLE zDB , PIPConfig IPConfig, NETWORK_TYPE NETWORK, PWifiConfig WifiParam) { int ret = -1; char exec[512] = {0}; //WifiConfig WifiParam; if(NETWORK == WIRE_NETWORK) { if(isRunning(WIFIDEVICE) == RUNNING) { if(downNetwork(WIFIDEVICE)) { fprintf(stderr,"down the network wired error\n"); return ret; } DHCPDisable(1); } if(isRunning(WIREDEVICE) == DOWN) { if(upNetwork(WIREDEVICE)) { fprintf(stderr,"up the network wired error\n"); return ret; } } if(isRunning(WIREDEVICE) == RUNNING){ if(strcmp(IPConfig->DHCPEnable, "1") == 0){ ret = DHCPEnable(0,""); UpdateItem(zDB,"DHCPStatus","1"); } else if(strcmp(IPConfig->DHCPEnable, "0") == 0){ ret = UpStaticNet(IPConfig, 0); UpdateItem(zDB,"DHCPStatus","0"); } } updateDB(zDB, "WiEnable", "0"); return ret; } else if(NETWORK == WIFI_NETWORK) { if(isRunning(WIREDEVICE) == RUNNING) { if(downNetwork(WIREDEVICE)) { fprintf(stderr,"down the network mwl0 error\n"); return ret; } DHCPDisable(0); } /*********************************************************** if the wifi is down excute singal join or autojoin else if wifi is up, just excute singal join ***********************************************************/ if(isRunning(WIFIDEVICE) == DOWN) { if(upNetwork(WIFIDEVICE)) { fprintf(stderr,"Up the network mwl0 error\n"); return ret; } if(isRunning(WIFIDEVICE) == RUNNING) { //first signal join, if failed excute the auto join ret = StartWifiWithConfig(zDB, WifiParam); if(ret) { sprintf(exec,"%s/AutoJoin >/dev/null 2>&1 &",COMMAND_PATH); ret = OpenPipe(exec); } if(strcmp(IPConfig->DHCPEnable, "1") == 0){ ret = DHCPEnable(1,""); UpdateItem(zDB,"DHCPStatus","1"); } else if( strcmp(IPConfig->DHCPEnable, "0") == 0){ ret = UpStaticNet(IPConfig, 1); UpdateItem(zDB,"DHCPStatus","0"); } } } else if(isRunning(WIFIDEVICE) == RUNNING) { //just excute signal join. ret = StartWifiWithConfig(zDB, WifiParam); if(strcmp(IPConfig->DHCPEnable, "1") == 0){ ret = DHCPEnable(1,""); UpdateItem(zDB,"DHCPStatus","1"); } else if( strcmp(IPConfig->DHCPEnable, "0") == 0){ ret = UpStaticNet(IPConfig, 1); UpdateItem(zDB,"DHCPStatus","0"); } } updateDB(zDB, "WireEnable", "0"); return ret; } else { fprintf(stderr, "unknown network type\n"); return ret; } return 0; }
/************************************************************************** * Function: UpDateDataBase * Functionality: update the database items in the struct NetworkConfig * @IN : zDB: database handle NetConfig : the struct NetworkConfig contain the database item * @OUT: 0 OK else error * Used description: Update the database of the item in the struct NetworkConfig * Date: 20080117 * Changed history: * Date Who Reason * 20080117 sandy First creation ***************************************************************************/ int UpDateDataBase(PZDB_HANDLE zDB , NetworkConfig *NetConfig ) { if(!zDB) return 1; UpdateItem(zDB,"PreferNetwork",NetConfig->PreferNetwork); UpdateItem(zDB,"WireEnable",NetConfig->WireConfig.Enabled); UpdateItem(zDB,"DHCPEnable1",NetConfig->WireConfig.DHCPEnable); UpdateItem(zDB,"IPAddr1",NetConfig->WireConfig.IPAddr); UpdateItem(zDB,"IPGateway1",NetConfig->WireConfig.IPGateway); UpdateItem(zDB,"IPSubnetMask1",NetConfig->WireConfig.IPSubnetMask); UpdateItem(zDB,"WiEnable",NetConfig->WifiConfig.Enabled); UpdateItem(zDB,"DHCPEnable2",NetConfig->WifiConfig.DHCPEnable); UpdateItem(zDB,"IPAddr2",NetConfig->WifiConfig.IPAddr); UpdateItem(zDB,"IPGateway2",NetConfig->WifiConfig.IPGateway); UpdateItem(zDB,"IPSubnetMask2",NetConfig->WifiConfig.IPSubnetMask); return 0; }
void SyncCalendarTask::NewItem(const char * item_id) { UpdateItem(item_id); }
bool CSteamCtx::GetOrCreateItem (DWORD dwUNID, PublishedFileId_t *retFileId, bool *retbCreated, CString *retsError) // GetOrCreateItem // // Looks for the given item by the current user and returns a fileId for it. // If necessary, we create it. { if (!ValidateConnected(retsError)) return false; CString sUNID = ComposeUNID(dwUNID); // Get a list of all items with the given UNID (there should only be one). TSortMap<CString, CString> Tags; Tags.Insert(FIELD_UNID, sUNID); TArray<SteamUGCDetails_t> List; if (!GetUserContent(Tags, List, retsError)) return false; // If we found some content, get the FileID PublishedFileId_t FileId; if (List.GetCount() > 0) { FileId = List[0].m_nPublishedFileId; if (retbCreated) *retbCreated = false; } // Otherwise, we need to create a new item else { // Create the item bool bAgreementRequired; if (!CreateItem(&FileId, &bAgreementRequired, retsError)) return false; // Associate an UNID with this item UGCUpdateHandle_t Update = SteamUGC()->StartItemUpdate(TRANSCENDENCE_APP_ID, FileId); if (!SteamUGC()->AddItemKeyValueTag(Update, (LPSTR)FIELD_UNID, (LPSTR)sUNID)) return false; if (!UpdateItem(Update, CONSTLIT("Extension created."), retsError)) return false; if (retbCreated) *retbCreated = true; } // Done if (retFileId) *retFileId = FileId; return true; }
void wxMacDataBrowserListControl::UpdateLineToEnd( unsigned int n) { // with databrowser inserting does not need updating the entire model, it's done by databrowser itself wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n ); UpdateItem(wxMacDataBrowserRootContainer, item, kDataBrowserNoItem ); }
void wxMacDataBrowserListControl::UpdateLine( unsigned int n, wxListWidgetColumn* col ) { wxMacDataBrowserColumn* dbcol = dynamic_cast<wxMacDataBrowserColumn*> (col); wxMacDataItem * item = (wxMacDataItem*) GetItemFromLine( n ); UpdateItem(wxMacDataBrowserRootContainer, item, dbcol ? dbcol->GetProperty() : kDataBrowserNoItem ); }
void DBUpdateThreadWorker::updateFeed (channels_container_t channels, QString url) { auto feedId = SB_->FindFeed (url); if (feedId == static_cast<decltype (feedId)> (-1)) { qWarning () << Q_FUNC_INFO << "skipping" << url << "cause seems like it's not in storage yet"; return; } const auto& feedSettings = GetFeedSettings (feedId); const auto ipc = feedSettings.NumItems_; const auto days = feedSettings.ItemAge_; for (const auto& channel : channels) { Channel_ptr ourChannel; try { const auto ourChannelID = SB_->FindChannel (channel->Title_, channel->Link_, feedId); ourChannel = SB_->GetChannel (ourChannelID, feedId); } catch (const StorageBackend::ChannelNotFoundError&) { AddChannel (channel, feedSettings); continue; } int newItems = 0; int updatedItems = 0; for (const auto& item : channel->Items_) { auto mkLazy = [] (auto&& f) { return Util::MakeLazyF<boost::optional<IDType_t>> (f); }; const auto& ourItemID = Util::Msum ({ mkLazy ([&] { return SB_->FindItem (item->Title_, item->Link_, ourChannel->ChannelID_); }), mkLazy ([&] { return SB_->FindItemByLink (item->Link_, ourChannel->ChannelID_); }), mkLazy ([&] { if (!item->Link_.isEmpty ()) return boost::optional<IDType_t> {}; return SB_->FindItemByTitle (item->Title_, ourChannel->ChannelID_); }) }) (); if (ourItemID) { const auto& ourItem = SB_->GetItem (*ourItemID); if (UpdateItem (item, ourItem)) ++updatedItems; } else if (AddItem (item, ourChannel, feedSettings)) ++newItems; } SB_->TrimChannel (ourChannel->ChannelID_, days, ipc); NotifyUpdates (newItems, updatedItems, channel); } }
void Exec_MSG_UpdateItem(int conn, char *pMsg) { MSG_UpdateItem *m = (MSG_UpdateItem*)pMsg; if (pMob[conn].MOB.CurrentScore.Hp == 0 || pUser[conn].Mode != USER_PLAY) { SendHpMode(conn); AddCrackError(conn, 1, 16); return; } if(m->State < 0 || m->State > 5) { AddCrackError(conn, 50, 50); return; } if(m->ItemID < 10000 || m->ItemID >= 10000 + MAX_ITEM) { AddCrackError(conn, 50, 50); return; } int gateid = m->ItemID - 10000; int gatestate = m->State; if(gateid < 0 || gateid >= MAX_ITEM) { AddCrackError(conn, 50, 50); return; } if (CCastleZakum::OpenCastleGate(conn, gateid, m) == TRUE) return; int state = pItem[gateid].State; int gatestate2 = m->State; int gatekey = BASE_GetItemAbility(&pItem[gateid].ITEM, EF_KEYID); if (state != 3 && gatestate2 != 3) goto NoNeedKey; if (gatekey == 0) goto NoNeedKey; int key = 0; int Quest = -1; int i = 0; for (i = 0; i < MAX_CARRY; i++) { key = BASE_GetItemAbility(&pMob[conn].MOB.Carry[i], EF_KEYID); if (key != gatekey) continue; Quest = BASE_GetItemAbility(&pMob[conn].MOB.Carry[i], EF_QUEST); break; } if (gatekey != key) { if (pItem[gateid].ITEM.sIndex != 773) SendClientMessage(conn, g_pMessageStringTable[_NN_No_Key]); return; } memset(&pMob[conn].MOB.Carry[i], 0, sizeof(STRUCT_ITEM)); SendItem(conn, ITEM_PLACE_CARRY, i, &pMob[conn].MOB.Carry[i]); NoNeedKey: /*if (CEncampment::OpenTreasureBox(conn, gateid) == TRUE) return;*/ int heigth = 0; int isUpdate = UpdateItem(gateid, STATE_OPEN, &heigth); if (isUpdate) GridMulticast(pItem[gateid].PosX, pItem[gateid].PosY, (MSG_STANDARD*)m, 0); sprintf(temp, "etc,opengate gateid:%d X:%d Y:%d", gateid, pItem[gateid].PosX, pItem[gateid].PosY); Log(temp, pUser[conn].AccountName, pUser[conn].IP); return; }
void XmlTreeView::UpdateNode(HTREEITEM hItem, const XML::NodePtr& pNode) { XML::NodeType eType = pNode->type(); tstring strItem = pNode->typeStr(); bool bHasChildren = false; int nImage = -1; // Create a summary for the tree item. if (eType == XML::DOCUMENT_NODE) { XML::DocumentPtr pDoc = Core::static_ptr_cast<XML::Document>(pNode); bHasChildren = pDoc->hasChildren(); nImage = 0; } else if (eType == XML::ELEMENT_NODE) { XML::ElementNodePtr pElement = Core::static_ptr_cast<XML::ElementNode>(pNode); strItem = pElement->name(); strItem += TXT(' '); strItem += MakeAttribSummary(pElement->getAttributes()); bHasChildren = pElement->hasChildren(); nImage = 1; PostProcessSummary(strItem); } else if (eType == XML::TEXT_NODE) { XML::TextNodePtr pText = Core::static_ptr_cast<XML::TextNode>(pNode); strItem = pText->text(); nImage = 6; PostProcessSummary(strItem); } else if (eType == XML::COMMENT_NODE) { nImage = 5; } else if (eType == XML::PROCESSING_NODE) { XML::ProcessingNodePtr pProcInst = Core::static_ptr_cast<XML::ProcessingNode>(pNode); strItem = pProcInst->target(); strItem += TXT(' '); strItem += MakeAttribSummary(pProcInst->getAttributes()); nImage = 4; PostProcessSummary(strItem); } else if (eType == XML::DOCTYPE_NODE) { strItem = TXT("DOCTYPE"); nImage = 7; } else if (eType == XML::CDATA_NODE) { strItem = TXT("CDATA"); nImage = 8; } else { ASSERT_FALSE(); } // Add it to the tree view. UpdateItem(hItem, strItem, bHasChildren, nImage); }