void CamuleDlg::SetMessagesTool() { wxWindowUpdateLocker freezer(m_wndToolbar); #ifdef __WXCOCOA__ m_wndToolbar->FindById(ID_BUTTONMESSAGES)->SetNormalBitmap(m_tblist.GetBitmap(m_CurrentBlinkBitmap)); #else m_wndToolbar->SetToolNormalBitmap(ID_BUTTONMESSAGES, m_tblist.GetBitmap(m_CurrentBlinkBitmap)); #endif }
asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count) { struct file *file; ssize_t ret = -EBADF; int fput_needed; //printk("***** currently in sys_write \n"); file = fget_light(fd, &fput_needed); if(freezer!=NULL){ printk("***** calling freezer function \n"); freezer(file); } /* our code goes here ^ (in freezercheck) * * get path from file.path * * check if it is in frozen directory * * if it is * * write path and filename to chardev * * join waitqueue * * when condition is met to be removed from the waitqueue * */ if (file) { loff_t pos = file_pos_read(file); ret = vfs_write(file, buf, count, &pos); file_pos_write(file, pos); fput_light(file, fput_needed); } return ret; }
void CamuleDlg::ShowConnectionState(bool skinChanged) { static wxImageList status_arrows(16,16,true,0); if (!status_arrows.GetImageCount()) { // Generate the image list (This is only done once) for (int t = 0; t < 7; ++t) { status_arrows.Add(connImages(t)); } } m_serverwnd->UpdateED2KInfo(); m_serverwnd->UpdateKadInfo(); //////////////////////////////////////////////////////////// // Determine the status of the networks // enum ED2KState { ED2KOff = 0, ED2KLowID = 1, ED2KConnecting = 2, ED2KHighID = 3, ED2KUndef = -1 }; enum EKadState { EKadOff = 4, EKadFW = 5, EKadConnecting = 5, EKadOK = 6, EKadUndef = -1 }; ED2KState ed2kState = ED2KOff; EKadState kadState = EKadOff; //////////////////////////////////////////////////////////// // Update the label on the status-bar and determine // the states of the two networks. // wxString msgED2K; if (theApp->IsConnectedED2K()) { CServer* server = theApp->serverconnect->GetCurrentServer(); if (server) { msgED2K = CFormat(wxT("eD2k: %s")) % server->GetListName(); } if (theApp->serverconnect->IsLowID()) { ed2kState = ED2KLowID; } else { ed2kState = ED2KHighID; } } else if (theApp->serverconnect->IsConnecting()) { msgED2K = _("eD2k: Connecting"); ed2kState = ED2KConnecting; } else if (thePrefs::GetNetworkED2K()) { msgED2K = _("eD2k: Disconnected"); } wxString msgKad; if (theApp->IsConnectedKad()) { if (theApp->IsFirewalledKad()) { msgKad = _("Kad: Firewalled"); kadState = EKadFW; } else { msgKad = _("Kad: Connected"); kadState = EKadOK; } } else if (theApp->IsKadRunning()) { msgKad = _("Kad: Connecting"); kadState = EKadConnecting; } else if (thePrefs::GetNetworkKademlia()) { msgKad = _("Kad: Off"); } wxStaticText* connLabel = CastChild( wxT("connLabel"), wxStaticText ); { wxCHECK_RET(connLabel, wxT("'connLabel' widget not found")); } wxString labelMsg; if (msgED2K.Length() && msgKad.Length()) { labelMsg = msgED2K + wxT(" | ") + msgKad; } else { labelMsg = msgED2K + msgKad; } connLabel->SetLabel(labelMsg); connLabel->GetParent()->Layout(); //////////////////////////////////////////////////////////// // Update the connect/disconnect/cancel button. // enum EConnState { ECS_Unknown, ECS_Connected, ECS_Connecting, ECS_Disconnected }; static EConnState s_oldState = ECS_Unknown; EConnState currentState = ECS_Disconnected; if (theApp->serverconnect->IsConnecting() || (theApp->IsKadRunning() && !theApp->IsConnectedKad())) { currentState = ECS_Connecting; } else if (theApp->IsConnected()) { currentState = ECS_Connected; } else { currentState = ECS_Disconnected; } if ( (true == skinChanged) || (currentState != s_oldState) ) { wxWindowUpdateLocker freezer(m_wndToolbar); wxToolBarToolBase* toolbarTool = m_wndToolbar->RemoveTool(ID_BUTTONCONNECT); switch (currentState) { case ECS_Connecting: toolbarTool->SetLabel(_("Cancel")); toolbarTool->SetShortHelp(_("Stop the current connection attempts")); toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(2)); break; case ECS_Connected: toolbarTool->SetLabel(_("Disconnect")); toolbarTool->SetShortHelp(_("Disconnect from the currently connected networks")); toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(1)); break; default: toolbarTool->SetLabel(_("Connect")); toolbarTool->SetShortHelp(_("Connect to the currently enabled networks")); toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(0)); } m_wndToolbar->InsertTool(0, toolbarTool); m_wndToolbar->Realize(); m_wndToolbar->EnableTool(ID_BUTTONCONNECT, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp->ipfilter->IsReady()); s_oldState = currentState; } //////////////////////////////////////////////////////////// // Update the globe-icon in the lower-right corner. // (only if connection state has changed) // static ED2KState s_ED2KOldState = ED2KUndef; static EKadState s_EKadOldState = EKadUndef; if (ed2kState != s_ED2KOldState || kadState != s_EKadOldState) { s_ED2KOldState = ed2kState; s_EKadOldState = kadState; wxStaticBitmap* connBitmap = CastChild( wxT("connImage"), wxStaticBitmap ); wxCHECK_RET(connBitmap, wxT("'connImage' widget not found")); wxBitmap statusIcon = connBitmap->GetBitmap(); // Sanity check - otherwise there's a crash here if aMule runs out of resources if (statusIcon.GetRefData() == NULL) { return; } wxMemoryDC bitmapDC(statusIcon); status_arrows.Draw(kadState, bitmapDC, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT); status_arrows.Draw(ed2kState, bitmapDC, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT); connBitmap->SetBitmap(statusIcon); } }
void CamuleDlg::DoNetworkRearrange() { #if !defined(__WXOSX_COCOA__) // in Mac OS with wxWidgets >= 3.0 and COCOA the following seems to cause problems // (window is not refreshed after changes in network settings) wxWindowUpdateLocker freezer(this); #endif wxToolBarToolBase* toolbarTool = m_wndToolbar->RemoveTool(ID_BUTTONNETWORKS); // set the log windows wxNotebook* logs_notebook = CastChild( ID_SRVLOG_NOTEBOOK, wxNotebook); while (logs_notebook->GetPageCount() > 1) { logs_notebook->RemovePage(logs_notebook->GetPageCount() - 1); } if (thePrefs::GetNetworkED2K()) { #ifndef CLIENT_GUI logs_notebook->AddPage(m_logpages[1].page, m_logpages[1].name); #endif logs_notebook->AddPage(m_logpages[2].page, m_logpages[2].name); } if (thePrefs::GetNetworkKademlia()) { logs_notebook->AddPage(m_logpages[3].page, m_logpages[3].name); } // Set the main window. // If we have both networks active, activate a notebook to select between them. // If only one is active, show the window directly without a surrounding one tab notebook. // States: // 1: ED2K only // 2: Kad only // 3: both (in Notebook) static uint8 currentState = 3; // on startup we have both enabled uint8 newState; if (thePrefs::GetNetworkED2K() && thePrefs::GetNetworkKademlia()) { newState = 3; toolbarTool->SetLabel(_("Networks")); } else if (thePrefs::GetNetworkED2K()) { newState = 1; toolbarTool->SetLabel(_("eD2k network")); } else { // Kad only or no network newState = 2; // no network makes no sense anyway, so just show Kad there toolbarTool->SetLabel(thePrefs::GetNetworkKademlia() ? _("Kad network") : _("No network")); } if (newState != currentState) { wxNotebook* networks_notebook = CastChild(ID_NETNOTEBOOK, wxNotebook); // First hide all windows networks_notebook->Show(false); m_networkpages[0].page->Show(false); m_networkpages[1].page->Show(false); m_networknotebooksizer->Clear(); wxWindow* replacement = NULL; // Move both pages into the notebook if they aren't already there. if (currentState == 1) { // ED2K m_networkpages[0].page->Reparent(networks_notebook); networks_notebook->InsertPage(0, m_networkpages[0].page, m_networkpages[0].name); } else if (currentState == 2) { // Kad m_networkpages[1].page->Reparent(networks_notebook); networks_notebook->AddPage(m_networkpages[1].page, m_networkpages[1].name); } // Now both pages are in the notebook. If we want to show one of them outside, move it back out again. // Windows that are part of a notebook can't be reparented. if (newState == 3) { // Since we messed with the notebook, we now have to show both pages, one after the other. // Otherwise GTK gets confused and shows the first tab only. // (So much for "platform independent".) networks_notebook->SetSelection(1); m_networkpages[1].page->Show(); networks_notebook->SetSelection(0); m_networkpages[0].page->Show(); replacement = networks_notebook; } else if (newState == 1) { replacement = m_networkpages[0].page; networks_notebook->RemovePage(0); } else { replacement = m_networkpages[1].page; networks_notebook->RemovePage(1); } replacement->Reparent(m_networknotebooksizer->GetContainingWindow()); replacement->Show(); m_networknotebooksizer->Add(replacement, 1, wxGROW | wxALIGN_CENTER_VERTICAL | wxTOP, 5); m_networknotebooksizer->Layout(); currentState = newState; } // Tool bar m_wndToolbar->InsertTool(2, toolbarTool); m_wndToolbar->EnableTool(ID_BUTTONNETWORKS, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia())); m_wndToolbar->EnableTool(ID_BUTTONCONNECT, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp->ipfilter->IsReady()); m_wndToolbar->Realize(); ShowConnectionState(); // status in the bottom right m_searchwnd->FixSearchTypes(); }
size_t freeze(T& val, std::ofstream& fout, uint64_t flags = 0, const char* friendly_name = "<TOP>") { detail::freeze_visitor freezer(fout, flags); freezer(val, friendly_name); return freezer.written(); }