예제 #1
0
HighlightLanguage EditorColourSet::AddHighlightLanguage(int lexer, const wxString& name)
{
    if (   lexer <= wxSCI_LEX_NULL
        || lexer >  wxSCI_LEX_LAST // this is a C::B extension to wxscintilla.h
        || name.IsEmpty())
    {
        return HL_NONE;
    }

    // fix name to be XML compliant
    wxString newID;
    size_t pos = 0;
    while (pos < name.Length())
    {
        wxChar ch = name[pos];
        if (wxIsalnum(ch) || ch == _T('_'))
        {
            // valid character
            newID.Append(ch);
        }
        else if (wxIsspace(ch))
        {
            // convert spaces to underscores
            newID.Append(_T('_'));
        }
        ++pos;
    }
    // make sure it's not starting with a number or underscore.
    // if it is, prepend an 'A'
    if (wxIsdigit(newID.GetChar(0)) || newID.GetChar(0) == _T('_'))
        newID.Prepend(_T('A'));

    if (GetHighlightLanguage(newID) != HL_NONE)
    {
        return HL_NONE;
    }

    m_Sets[newID].m_Langs = name;
    m_Sets[newID].m_Lexers = lexer;
    return newID;
}
예제 #2
0
void CBaseMenuEdit::SetLocus(
  const wxString &s, 
  bool bEnabled
  )
{
  m_pMenuReview->SetLocusName(s);
  m_pMenuAccept->SetLocusName(s);
  if(s.IsEmpty())
  {
    SetLabel(IDmenuEditCell,EDIT_SAMPLE_LABEL);
  }
  else
  {
    wxString sLabel;
    sLabel = "Edit ";
    sLabel.Append(s);
    sLabel.Append("...");
    SetLabel(IDmenuEditCell,sLabel);
  }
  Enable(IDmenuEditCell,bEnabled);
}
예제 #3
0
파일: Path.cpp 프로젝트: dreamerc/amule
CPath CPath::AppendExt(const wxString& ext) const
{
	wxASSERT(ext.IsAscii());

	// Though technically, and empty extension would simply 
	// be another . at the end of the filename, we ignore them.
	if (ext.IsEmpty()) {
		return *this;
	}

	CPath result(*this);
	if (ext[0] == wxT('.')) {
		result.m_printable << ext;
		result.m_filesystem << ext;
	} else {
		result.m_printable << wxT(".") << ext;
		result.m_filesystem << wxT(".") << ext;
	}

	return result;
}
예제 #4
0
void WxGuiTestHelper::AddTestFailure (const wxString &file, const int line,
        const wxString &shortDescription, const wxString &message)
{
    if (s_accTestFailures.IsEmpty ()) {

        s_fileOfFirstTestFailure = file;
        s_lineNmbOfFirstTestFailure = line;
        s_shortDescriptionOfFirstTestFailure = shortDescription;

    } else {

        s_accTestFailures += _T("\nAND SUBSEQUENTLY:");
        if (!shortDescription.IsEmpty ()) {

            s_accTestFailures += _T("\n");
            s_accTestFailures += shortDescription;
        }
    }
    s_accTestFailures += _T("\n");
    s_accTestFailures += message;
}
예제 #5
0
bool pgsRecord::set_column_name(const USHORT &column, wxString name)
{
	// Column number must be valid
	if (column >= count_columns())
	{
		return false;
	}

	// Column name must not exist
	// Column name must not be empty
	name = name.Strip(wxString::both).Lower();
	if (m_columns.Index(name) != wxNOT_FOUND || name.IsEmpty())
	{
		return false;
	}

	// Set the column name
	m_columns[column] = name;

	return true;
}
//---------------------------------------------------------
void CINFO_Messages::Add_String(wxString sMessage, bool bNewLine, bool bTime, TSG_UI_MSG_STYLE Style)
{
	if( !sMessage.IsEmpty() )
	{
		if( bNewLine )
		{
			_Add_Text(wxT("\n"));
		}

		if( bTime )
		{
			Add_Time(false);

			_Add_Text(wxT(" "));
		}

		_Set_Style(Style);

		_Add_Text(sMessage);
	}
}
예제 #7
0
void pgPassConfigLine::Init(const wxString &line)
{
	text = line;

	if (line.IsEmpty())
		return;

	isComment = line.StartsWith(wxT("#"));

	wxStringTokenizer tok(isComment ? line.Mid(1) : line, wxT(":"));
	if (tok.HasMoreTokens())
		hostname = tok.GetNextToken();
	if (tok.HasMoreTokens())
		port = tok.GetNextToken();
	if (tok.HasMoreTokens())
		database = tok.GetNextToken();
	if (tok.HasMoreTokens())
		username = tok.GetNextToken();
	if (tok.HasMoreTokens())
		password = tok.GetNextToken();
}
예제 #8
0
bool MSVC7Loader::ParseInputString(const wxString& Input, wxArrayString& Output)
{
    /* This function will parse an input string recursively
     * with separators (',' and ';') */
    wxArrayString Array1, Array2;
    if (Input.IsEmpty())
        return false;
    Array1 = GetArrayFromString(Input, _T(","));
    for (size_t i = 0; i < Array1.GetCount(); ++i)
    {
        if (Array1[i].Find(_T(";")) != -1)
        {
            Array2 = GetArrayFromString(Array1[i], _T(";"));
            for (size_t j = 0; j < Array2.GetCount(); ++j)
                Output.Add(Array2[j]);
        }
        else
            Output.Add(Array1[i]);
    }
    return true;
}
예제 #9
0
bool Identifier::needsQuoting(const wxString& s)
{
    if (s.IsEmpty())
        return false;
    const wxChar* p = s.c_str();
    // first character: only 'A'..'Z' allowed, else quotes needed
    if (*p < 'A' || *p > 'Z')
        return true;
    p++;
    // after first character: 'A'..'Z', '0'..'9', '_', '$' allowed
    while (*p != 0)
    {
        bool validChar = (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9')
            || *p == '_' || *p == '$';
        if (!validChar)
            return true;
        p++;
    }
    // may still need quotes if reserved word
    return SqlTokenizer::isReservedWord(s);
}
예제 #10
0
void BatchCommands::Split(const wxString & str, wxString & command, wxString & param)
{
   int splitAt;

   command.Empty();
   param.Empty();

   if (str.IsEmpty()) {
      return;
   }

   splitAt = str.Find(wxT(':'));
   if (splitAt < 0) {
      return;
   }

   command = str.Mid(0, splitAt);
   param = str.Mid(splitAt + 1);

   return;
}
예제 #11
0
/// Convenience function for setting the major attributes for a list level specification
void wxRichTextListStyleDefinition::SetAttributes(int i, int leftIndent, int leftSubIndent, int bulletStyle, const wxString& bulletSymbol)
{
    wxASSERT( (i >= 0 && i < 10) );
    if (i >= 0 && i < 10)
    {
        wxRichTextAttr attr;

        attr.SetBulletStyle(bulletStyle);
        attr.SetLeftIndent(leftIndent, leftSubIndent);

        if (!bulletSymbol.IsEmpty())
        {
            if (bulletStyle & wxTEXT_ATTR_BULLET_STYLE_SYMBOL)
                attr.SetBulletText(bulletSymbol);
            else
                attr.SetBulletName(bulletSymbol);
        }

        m_levelStyles[i] = attr;
    }
}
예제 #12
0
파일: update.cpp 프로젝트: dnjsflagh1/code
// 配置文件读写	
bool CUpdate::setConfig(const wxString& key, const wxString& values, wxString fileName)
{
	if(fileName.IsEmpty())
	{
		fileName = m_configFile;
	}
	wxString	realFileName = m_skinDir +fileName;
	wxFileInputStream fis(realFileName);
	if (!fis.Ok())
	{
		assert("Config file not found.");
		return false;
	}
	wxFileConfig *conf = new wxFileConfig(fis);
	bool result = conf->Write(key, values);
	wxFileOutputStream os(realFileName);
	conf->Save(os);
	os.Close();	
	delete conf;
	return result;
}
예제 #13
0
void TabgroupManager::LoadTabgroupData(const wxString& tabgroup)
{
    // 'tabgroup' is the filepath of the tabgroup to load
    if(tabgroup.IsEmpty()) {
        return;
    }

    // Load the data: we're only interested in the tab names here, not each CurrentLine etc
    TabGroupEntry session;
    wxString filepath = tabgroup.BeforeLast(wxT('.')); // FindSession() doesn't want the .ext here
    if(SessionManager::Get().GetSession(filepath, session, "tabgroup", tabgroupTag)) {
        wxArrayString tabnames;
        const std::vector<TabInfo>& vTabInfoArr = session.GetTabInfoArr();
        for(size_t i = 0; i < vTabInfoArr.size(); ++i) {
            const TabInfo& ti = vTabInfoArr[i];
            tabnames.Add(ti.GetFileName());
        }
        std::pair<wxString, wxArrayString> TabgroupItem(tabgroup, tabnames);
        m_tabgroups.push_back(TabgroupItem);
    }
}
예제 #14
0
bool TabgroupManager::DoAddItemToTabgroup(
    wxXmlDocument& doc, wxXmlNode* node, const wxString& filepath, const wxString& nextitemfilepath)
{
    wxXmlNode* TabInfoArrayNode = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("TabInfoArray"));
    if(!TabInfoArrayNode) {
        return false;
    }

    // If previousnode is valid, insert the new tab after it
    wxXmlNode* previousnode = NULL;
    if(!nextitemfilepath.IsEmpty()) {
        previousnode = FindTabgroupItem(doc, filepath, nextitemfilepath);
    }
    if(previousnode) {
        return TabInfoArrayNode->InsertChildAfter(node, previousnode); // >=2.8.8 has a convenient function to do this
    } else {
        TabInfoArrayNode->AddChild(node);
    }

    return true;
}
예제 #15
0
void WinEDA_BasicFrame::SetLastProject(const wxString & FullFileName)
/*******************************************************************/
/* Met a jour la liste des anciens projets
*/
{
unsigned ii;

	if ( FullFileName.IsEmpty() ) return;

	//suppression d'une ancienne trace eventuelle du meme fichier
	for ( ii = 0; ii < m_Parent->m_LastProject.GetCount(); )
	{
		if(m_Parent->m_LastProject[ii].IsEmpty() ) break;
#ifdef __WINDOWS__
		if ( m_Parent->m_LastProject[ii].CmpNoCase(FullFileName) == 0 )
#else
		if ( m_Parent->m_LastProject[ii] == FullFileName )
#endif
		{
#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4)) )
			m_Parent->m_LastProject.Remove(ii);
#else
			m_Parent->m_LastProject.RemoveAt(ii);
#endif
		}
		else ii++;
	}

    while (m_Parent->m_LastProject.GetCount() >= m_Parent->m_LastProjectMaxCount)
    {
#if ( (wxMAJOR_VERSION < 2) || ((wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION <= 4)) )
        files.Remove(files.GetCount() - 1);
#else
        m_Parent->m_LastProject.RemoveAt(m_Parent->m_LastProject.GetCount() - 1);
#endif
    }
	m_Parent->m_LastProject.Insert(FullFileName, 0);

	ReCreateMenuBar();
}
예제 #16
0
void DoSelectRememberedNode(wxTreeCtrl* tree, const wxTreeItemId& parent, wxString& selectedItemPath)
{
    if (tree && !selectedItemPath.IsEmpty())
    {
        wxString tmpPath;
        wxString folder;
        tmpPath = selectedItemPath;
        int pos = tmpPath.Find(_T('/'));
        while (pos == 0)
        {
            tmpPath = tmpPath.Right(tmpPath.Length() - pos - 1);
            pos = tmpPath.Find(_T('/'));
        }

        folder = tmpPath.Left(pos);
        tmpPath = tmpPath.Right(tmpPath.Length() - pos - 1);
        wxTreeItemId item = parent;
        wxTreeItemIdValue cookie = nullptr;

        while (item.IsOk())
        {
            if (tree->GetItemText(item) != folder)
                item = tree->GetNextSibling(item);
            else
            {
                if (pos < 0)
                {
                    tree->SelectItem(item);
                    break;
                }
                else
                {
                    item = tree->GetNextChild(item, cookie);
                    DoSelectRememberedNode(tree, item, tmpPath);
                }
            }
        }

    }
}
예제 #17
0
bool LLDBPlugin::DoInitializeDebugger(clDebugEvent& event, bool redirectOutput, const wxString& terminalTitle)
{
    if ( event.GetDebuggerName() != LLDB_DEBUGGER_NAME ) {
        event.Skip();
        return false;
    }

    if ( m_connector.IsRunning() ) {
        // Another debug session is already in progress
        ::wxMessageBox(_("Another debug session is already in progress. Please stop it first"), "CodeLite", wxOK|wxCENTER|wxICON_WARNING);
        return false;
    }
    
    TerminateTerminal();
    
    // If terminal is required, launch it now
    if ( redirectOutput ) {
        ::LaunchTerminalForDebugger(terminalTitle.IsEmpty() ? event.GetExecutableName() : terminalTitle , m_terminalTTY, m_terminalPID);
    
        if ( m_terminalPID != wxNOT_FOUND ) {
            CL_DEBUG("Successfully launched terminal");
        
        } else {
            // Failed to launch it...
            DoCleanup();
            ::wxMessageBox(_("Failed to start terminal for debugger"), "CodeLite", wxICON_ERROR|wxOK|wxCENTER);
            return false;
        }
    }
    
    // Launch local server if needed
    LLDBSettings settings;
    settings.Load();
    if ( !settings.IsUsingRemoteProxy() && !m_connector.LaunchLocalDebugServer() ) {
        DoCleanup();
        return false;
    }
    
    return true;
}
예제 #18
0
wxString FileNames::DataDir()
{
   // LLL:  Wouldn't you know that as of WX 2.6.2, there is a conflict
   //       between wxStandardPaths and wxConfig under Linux.  The latter
   //       creates a normal file as "$HOME/.audacity", while the former
   //       expects the ".audacity" portion to be a directory.
   if (gDataDir.IsEmpty())
   {
      // If there is a directory "Portable Settings" relative to the
      // executable's EXE file, the prefs are stored in there, otherwise
      // the prefs are stored in the user data dir provided by the OS.
      wxFileName exePath(PlatformCompatibility::GetExecutablePath());
#if defined(__WXMAC__)
      // This removes (for instance) "Audacity.app/Contents/MacOSX"
      exePath.RemoveLastDir();
      exePath.RemoveLastDir();
      exePath.RemoveLastDir();
#endif
      wxFileName portablePrefsPath(exePath.GetPath(), wxT("Portable Settings"));
      
      if (::wxDirExists(portablePrefsPath.GetFullPath()))
      {
         // Use "Portable Settings" folder
         gDataDir = portablePrefsPath.GetFullPath();
      } else
      {
         // Use OS-provided user data dir folder
         wxString dataDir;
#if defined( __WXGTK__ )
         dataDir = wxStandardPaths::Get().GetUserDataDir() + wxT("-data");
#else
         dataDir = wxStandardPaths::Get().GetUserDataDir();
#endif

         gDataDir = FileNames::MkDir(dataDir);
      }
   }
   
   return gDataDir;
}
예제 #19
0
bool wxGISServer::SetupLog(const wxString &sLogPath)
{
	if(sLogPath.IsEmpty())
	{
		wxLogError(_("wxGISServer: Failed to get log folder"));
        return false;
	}

	if(!wxDirExists(sLogPath))
		wxFileName::Mkdir(sLogPath, 0777, wxPATH_MKDIR_FULL);


	wxDateTime dt(wxDateTime::Now());
	wxString logfilename = sLogPath + wxFileName::GetPathSeparator() + wxString::Format(wxT("srvlog_%.4d%.2d%.2d.log"),dt.GetYear(), dt.GetMonth() + 1, dt.GetDay());

    if(m_LogFile.IsOpened())
        m_LogFile.Close();

	if(!m_LogFile.Open(logfilename.GetData(), wxT("a+")))
		wxLogError(_("wxGISServer: Failed to open log file %s"), logfilename.c_str());

	wxLog::SetActiveTarget(new wxLogStderr(m_LogFile.fp()));

#ifdef WXGISPORTABLE
	wxLogMessage(wxT("Portable"));
#endif
	wxLogMessage(wxT(" "));
	wxLogMessage(wxT("####################################################################"));
	wxLogMessage(wxT("##                    %s                    ##"),wxNow().c_str());
	wxLogMessage(wxT("####################################################################"));
	long dFreeMem =  wxMemorySize(wxGetFreeMemory() / 1048576).ToLong();
	wxLogMessage(_("HOST '%s': OS desc - %s, free memory - %u Mb"), wxGetFullHostName().c_str(), wxGetOsDescription().c_str(), dFreeMem);
	wxLogMessage(_("wxGISServer: %s %s is initializing..."), GetAppName().c_str(), GetAppVersionString().c_str());
	wxLogMessage(_("wxGISServer: Log file: %s"), logfilename.c_str());

	wxString sCPLLogPath = sLogPath + wxFileName::GetPathSeparator() + wxString(wxT("gdal_log_cat.txt"));
	CPLString szCPLLogPath(sCPLLogPath.mb_str(wxConvUTF8));
	CPLSetConfigOption("CPL_LOG", szCPLLogPath );
    return true;
}
예제 #20
0
파일: penvhelper.cpp 프로젝트: Sneedd/penv
//----------------------------------------------------------------
void PenvHelper::SplitString(const wxString& string, wxArrayString* array, wxChar separator)
/**
 * \brief Splits a string with a given separator into a string array.
 * The array must be initialized and empty. The array contains at least
 * one item after calling this method.
 * \param string String to split.
 * \param array Array with the splitted results.
 * \param separator Separator.
 **/
{
    if (unlikely(string.IsEmpty() || array == NULL)) return;
    int splitstringindex = 0;
    for (size_t i=0; i<string.Length(); ++i)
    {
        if (unlikely(string[i] == separator)) {
            array->Add(string.Mid(splitstringindex, i-splitstringindex));
            splitstringindex = i+1;
        }
    }
    array->Add(string.Mid(splitstringindex));
//    for (size_t i=0; i<array->Count(); ++i) wxLogMessage((*array)[i]);
}
void RemoveType( wxString type )
{
	if( type.IsEmpty() ) { return; }

	wxString value, old_default;
	wxString madedit_type = wxString( wxT( "MadEdit-Mod" ) ) + type;
	wxRegKey *pRegKey = new wxRegKey( g_MadEditRegkeyPath + type );

	if( pRegKey->Exists() )
	{
		pRegKey->QueryValue( wxT( "Old_Default" ), old_default );
		pRegKey->QueryValue( wxEmptyString, value );
	}

	if( !old_default.IsEmpty() )
	{
		pRegKey->DeleteValue( wxT( "Old_Default" ) );
		pRegKey->SetValue( wxEmptyString, old_default );
	}
	else
		if( !value.IsEmpty() )
		{
			if( value == madedit_type )
			{
				pRegKey->DeleteSelf();
			}
		}

	delete pRegKey;

	if( value == madedit_type )
	{
		pRegKey = new wxRegKey( g_MadEditRegkeyPath + value );

		if( pRegKey->Exists() ) { pRegKey->DeleteSelf(); }

		delete pRegKey;
	}
}
예제 #22
0
//---------------------------------------------------------
bool		DLG_Parameters(CSG_Parameters *pParameters, const wxString &Caption)
{
	bool	bResult	= false;

	if( pParameters && pParameters->Get_Count() > 0 )
	{
		CSG_String	Name	= pParameters->Get_Name();

		if( !Caption.IsEmpty() )
		{
			pParameters->Set_Name(&Caption);
		}

		CDLG_Parameters	dlg(pParameters);

		bResult	= dlg.ShowModal() == wxID_OK;

		pParameters->Set_Name(Name);
	}

	return( bResult );
}
CDVRPTRControllerV2::CDVRPTRControllerV2(const wxString& port, const wxString& path, bool txInvert, unsigned int modLevel, bool duplex) :
wxThread(wxTHREAD_JOINABLE),
m_port(port),
m_path(path),
m_txInvert(txInvert),
m_modLevel(modLevel),
m_duplex(duplex),
m_serial(port, SERIAL_115200),
m_buffer(NULL),
m_rxData(1000U),
m_txData(1000U),
m_counter(0U),
m_ptt(false),
m_rx(false),
m_space(0U),
m_stopped(false),
m_mutex()
{
	wxASSERT(!port.IsEmpty());

	m_buffer = new unsigned char[BUFFER_LENGTH];
}
예제 #24
0
void main_listctrl::launch_dialog_for_new_channel( const wxString& new_channel_section )
{
    if ( new_channel_section.IsEmpty() ) 
    {
        wxLogError( "Error: can't open a channel dialog for an empty section." );
        return;
    }
    
    wxString channel_section = new_channel_section;
    
    // Show the configuration dialog, ready to edit the new channel.
    // Can't make them a child of this window (freezes) or parent (since an
    // XRC unknown container and says 2 things can't occupy it), so needs to be a 
    // child of the main_frame (probably could be grandparent, but this is more 
    // readable).
    channel_dialog a_channel_dialog( m_parent, channel_section );
    
    // Show modal, and if clicked OK, then refresh the row, which will repaint as required.
    if ( a_channel_dialog.ShowModal() == wxID_OK ) 
    {    
        // insert_row also adds it to our array
        insert_row( channel_section );
    } 
    else
    {
        // Cancel button on channel dialog was clicked
        wxLogDebug( "main_listctrl::launch_dialog_for_new_channel != wxID_OK so flushing..." );
     
        // If didn't return OK, then must have clicked cancel to close the channel dialog
        // Since canceled before finished adding the chennel, delete the channel. No
        // gui delete needed, since never inserted the row.            
        plucker_controller::get()->delete_channel( channel_section );       
        wxLogDebug( "...and plucker_controller::delete_channel was called..." );        
        
        // Then flush again to write the new configuration with the section now removed.
        the_configuration->Flush();                
        wxLogDebug( ".. and finally Flush()'ed the configuration to write the deletion" );
    }               
}
예제 #25
0
int CDirList::ExtToType(const wxString &_sExt)
{
  int nRtn = _sExt.IsEmpty() ? CDirList::FILE_FSA : 0;
  if(!nRtn)
  {
    wxString sExt("*.");
    sExt.Append(_sExt);
    sExt.MakeLower();
    INITMAP();
    for(FILE_MAP::iterator itr = g_mapFileSpec.begin();
      itr != g_mapFileSpec.end();
      ++itr)
    {
      if(!itr->second.CmpNoCase(sExt))
      {
        nRtn = itr->first;
        break;
      }
    }
  }
  return nRtn;
}
예제 #26
0
bool SjBusyInfo::Set__(const wxString& object, bool forceUpdateForLongOp)
{
	static bool inSet = FALSE;

	if( !inSet )
	{
		inSet = TRUE;

		unsigned long currMs = SjTools::GetMsTicks();
		if( !object.IsEmpty() )
		{
			m_objectCount++;
			wxLogDebug(wxT("m_objectCount=%i on SjBusyInfo::Set__(%s)"), (int)m_objectCount, object.c_str());

			if( forceUpdateForLongOp || currMs >= m_nextUpdateMs )
			{
				wxString label(object);
				if( label.StartsWith("file:") ) { label = wxFileSystem::URLToFileName(object).GetFullPath(); }

				m_objectNameWindow->SetLabel(label);
				m_objectCountWindow->SetLabel(SjTools::FormatNumber(m_objectCount));
				m_nextUpdateMs = currMs + UPDATE_INTERVALL_MS;
			}
		}

		unsigned long elapsedSeconds = (currMs-m_startTimeMs)/1000;
		if( elapsedSeconds != m_elapsedSeconds )
		{
			m_elapsedTimeWindow->SetLabel(SjTools::FormatTime(elapsedSeconds, SJ_FT_ALLOW_ZERO));
			m_elapsedSeconds = elapsedSeconds;
		}

		Yield();

		inSet = FALSE;
	}

	return !m_cancelPressed;
}
예제 #27
0
void HelpPlugin::AddToPopupMenu(wxMenu *menu, int id, const wxString &help, bool
#ifdef __WXMSW__
    fromIni
#endif
)
{
  if (!help.IsEmpty())
  {
#ifdef __WXMSW__
    if (fromIni)
    {
      wxMenuItem *mitem = new wxMenuItem(0, id, help);
      wxFont &font = mitem->GetFont();
      font.SetWeight(wxFONTWEIGHT_BOLD);
      mitem->SetFont(font);
      menu->Append(mitem);
    }
    else
#endif
      menu->Append(id, help);
  }
}
예제 #28
0
bool wxGISApplication::SetupLog(const wxString &sLogPath, const wxString &sNamePrefix)
{
	if(sLogPath.IsEmpty())
	{
		wxLogError(_("wxGISApplication: Failed to get log folder"));
        return false;
	}

	if(!wxDirExists(sLogPath))
		wxFileName::Mkdir(sLogPath, 0777, wxPATH_MKDIR_FULL);


	wxDateTime dt(wxDateTime::Now());
	wxString logfilename = sLogPath + wxFileName::GetPathSeparator() + wxString::Format(wxT("%slog_%.4d%.2d%.2d.log"),sNamePrefix.c_str(), dt.GetYear(), dt.GetMonth() + 1, dt.GetDay());

    if(m_LogFile.IsOpened())
        m_LogFile.Close();

	if(!m_LogFile.Open(logfilename.GetData(), wxT("a+")))
		wxLogError(_("wxGISApplication: Failed to open log file %s"), logfilename.c_str());

	wxLog::SetActiveTarget(new wxLogStderr(m_LogFile.fp()));

#ifdef WXGISPORTABLE
	wxLogMessage(wxT("Portable"));
#endif
	wxLogMessage(wxT(" "));
	wxLogMessage(wxT("####################################################################"));
	wxLogMessage(wxT("##                    %s                    ##"),wxNow().c_str());
	wxLogMessage(wxT("####################################################################"));
    wxLongLong nFreeMem = wxGetFreeMemory();
    wxString sFreeMem = wxFileName::GetHumanReadableSize(wxULongLong(nFreeMem.GetHi(), nFreeMem.GetLo()));
//	long dFreeMem =  wxMemorySize(wxGetFreeMemory() / 1048576).ToLong();
	wxLogMessage(_("HOST '%s': OS desc - %s, free memory - %s"), wxGetFullHostName().c_str(), wxGetOsDescription().c_str(), sFreeMem.c_str());
	wxLogMessage(_("wxGISApplication: %s %s is initializing..."), GetAppName().c_str(), GetAppVersionString().c_str());
	wxLogMessage(_("wxGISApplication: Log file: %s"), logfilename.c_str());

    return true;
}
bool CslIrcSession::LeaveChannel(const wxString& name,const wxString& reason)
{
    if (!CslIrcEngine::GetThread() || m_state!=STATE_CONNECTED)
        return false;

    CslIrcChannel *channel=FindChannel(name);

    if (!channel)
        return false;

    m_channels.Remove(channel);

    if (!channel->Connected)
        return false;

    wxString command=wxT("PART ")+channel->Name;

    if (!reason.IsEmpty())
        command<<wxT(" :")<<reason;

    return SendRawCommand(command);
}
예제 #30
0
bool FileCSV::Save(const wxString& fileName)
{
    // Make sure file exists
    if (fileName.IsEmpty())
    {
        mmErrorDialogs::InvalidFile(pParentWindow_);
        return false;
    }

    // Open file
    wxTextFile txtFile(fileName);
    if (!txtFile.Create())
    {
        mmErrorDialogs::MessageError(pParentWindow_, _("Unable to create file."), _("Universal CSV Import"));
        return false;
    }

    // Store lines
    for (auto rowIt : itemsTable_)
    {
        wxString line;
        for (auto itemIt : rowIt)
        {
            if (!line.IsEmpty())
                line += delimiter_;
            line += inQuotes(itemIt.value, delimiter_);
        }
        txtFile.AddLine(line);
    }

    // Save the file.
    if (!txtFile.Write(wxTextFileType_None, encoding_))
    {
        mmErrorDialogs::MessageError(pParentWindow_, _("Could not save file."), _("Export error"));
        return false;
    }
    txtFile.Close();
    return true;
}