void wxGxDiscConnections::CreateConnectionsStorage(void)
{
    wxLogMessage(_("wxGxDiscConnections: Start scan folder connections"));
    wxArrayString arr;
#ifdef __WXMSW__
    arr = wxFSVolumeBase::GetVolumes(wxFS_VOL_MOUNTED, wxFS_VOL_REMOVABLE);//| wxFS_VOL_REMOTE
#else
    //linux paths
    wxStandardPaths stp;
    arr.Add(wxT("/"));
    arr.Add(stp.GetUserConfigDir());
//      arr.Add(stp.GetDataDir());
#endif
    //create
    wxXmlNode* pRootNode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("DiscConnections"));
    SetDecimalValue(pRootNode, wxT("ver"), 2);
    wxXmlDocument doc;
    doc.SetRoot(pRootNode);
    for(size_t i = 0; i < arr.size(); ++i)
    {
        wxXmlNode* pDiscConn = new wxXmlNode(pRootNode, wxXML_ELEMENT_NODE, wxT("DiscConnection"));
        pDiscConn->AddAttribute(wxT("name"), arr[i]);
        pDiscConn->AddAttribute(wxT("path"), arr[i]);
        SetDecimalValue(pDiscConn, wxT("id"), (int)i);
    }
    doc.Save(m_sXmlStoragePath);
}
/*
void wxGxDiscConnections::EmptyChildren(void)
{
    m_aConnections.clear();
	for(size_t i = 0; i < m_Children.size(); ++i)
	{
        wxGxDiscConnection* pwxGxDiscConnection = dynamic_cast<wxGxDiscConnection*>(m_Children[i]);
        if(pwxGxDiscConnection)
        {
            CONN_DATA data = {pwxGxDiscConnection->GetName(), pwxGxDiscConnection->GetInternalName()};
            m_aConnections.push_back(data);
        }
		m_Children[i]->Detach();
		wxDELETE(m_Children[i]);
	}
	m_Children.clear();
	m_bIsChildrenLoaded = false;
}

bool wxGxDiscConnections::DeleteChild(IGxObject* pChild)
{
	bool bHasChildren = m_Children.size() > 0 ? true : false;
    long nChildID = pChild->GetID();
	if(!IGxObjectContainer::DeleteChild(pChild))
		return false;
    m_pCatalog->ObjectDeleted(nChildID);
	if(bHasChildren != m_Children.size() > 0 ? true : false)
		m_pCatalog->ObjectChanged(GetID());
	return true;
}

void wxGxDiscConnections::LoadChildren(void)
{
	if(m_bIsChildrenLoaded)
		return;

    for(size_t i = 0; i < m_aConnections.size(); ++i)
    {
        wxGxDiscConnection* pwxGxDiscConnection = new wxGxDiscConnection(m_aConnections[i].sPath, m_aConnections[i].sName);
        IGxObject* pGxObject = static_cast<IGxObject*>(pwxGxDiscConnection);
        if(AddChild(pGxObject))
            wxLogVerbose(_("wxGxDiscConnections: Add folder connection [%s]"), m_aConnections[i].sName.c_str());
    }

	m_bIsChildrenLoaded = true;
}
*/
bool wxGxDiscConnections::ConnectFolder(const wxString &sPath)
{
    wxCriticalSectionLocker locker(m_oCritSect);
    if(!wxDir::Exists(sPath))
        return false;
    //find max id
    int nMaxId(0);
    wxGxObjectList ObjectList = GetChildren();
    wxGxObjectList::iterator iter;
    for (iter = ObjectList.begin(); iter != ObjectList.end(); ++iter)
    {
        wxGxObject *current = *iter;
        wxGxDiscConnection* pConn = wxDynamicCast(current, wxGxDiscConnection);
        if(!pConn)
            continue;
        if(nMaxId < pConn->GetXmlId())
            nMaxId = pConn->GetXmlId();
    }
    //add
    wxXmlDocument doc;
    //try to load connections xml file
    if(doc.Load(m_sXmlStoragePath))
    {
        wxXmlNode* pConnectionsNode = doc.GetRoot();
        wxXmlNode* pDiscConn = new wxXmlNode(pConnectionsNode, wxXML_ELEMENT_NODE, wxT("DiscConnection"));

        pDiscConn->AddAttribute(wxT("name"), sPath);
        pDiscConn->AddAttribute(wxT("path"), sPath);
        SetDecimalValue(pDiscConn, wxT("id"), nMaxId + 1);

        return doc.Save(m_sXmlStoragePath);
    }
    return false;
}
Exemple #3
0
wxGISEnumReturnType wxGISTaskManager::StopTask(int nTaskId, wxString & sMsg)
{
    if(m_moTasks[nTaskId] && (m_moTasks[nTaskId]->GetState() == enumGISTaskPaused || m_moTasks[nTaskId]->GetState() == enumGISTaskError || m_moTasks[nTaskId]->GetState() == enumGISTaskDone))
    {
        sMsg = wxString::Format(_("The task %d already stopped"), nTaskId);
        return enumGISReturnFailed;
    }
    long nId = wxNewId();
    wxNetMessage msg(enumGISNetCmdCmd, enumGISCmdStStop, enumGISPriorityHigh, nId);
    wxXmlNode* pRootNode = msg.GetXMLRoot();
    if(pRootNode)
    {
        wxXmlNode* pNode = new wxXmlNode(pRootNode, wxXML_ELEMENT_NODE, wxT("task"));
        wxGISTask* pTask = GetTask(nTaskId);
        pNode->AddAttribute(wxT("cat"), pTask->GetCategory());
        SetDecimalValue(pNode, wxT("id"), nTaskId);
        m_pConn->SendNetMessage(msg);
    }
    else
    {
        sMsg = wxString(_("Net message create failed"));
        return enumGISReturnFailed;
    }
    return Wait(nId, sMsg);
}
Exemple #4
0
wxGISEnumReturnType wxGISTaskManager::AddTask(const wxString &sCategory, int nMaxExecTaskCount, const wxString &sName, const wxString &sDesc, const wxString &sPath, long nPriority, const wxXmlNode *pParameters, wxString & sMsg)
{
    long nId = wxNewId();

    wxNetMessage msg(enumGISNetCmdCmd, enumGISCmdStAdd, enumGISPriorityHigh, nId);
    wxXmlNode* pRootNode = msg.GetXMLRoot();
    if(pRootNode)
    {
        wxXmlNode* pNode = new wxXmlNode(pRootNode, wxXML_ELEMENT_NODE, wxT("task"));
        pNode->AddAttribute(wxT("cat"), sCategory);
        //for new cat creation
        SetDecimalValue(pNode, wxT("cat_max_task_exec"), nMaxExecTaskCount);
        pNode->AddAttribute(wxT("name"), sName);
        pNode->AddAttribute(wxT("desc"), sDesc);
        pNode->AddAttribute(wxT("exec"), sPath);
        SetDecimalValue(pNode, wxT("prio"), nPriority);
        SetDecimalValue(pNode, wxT("state"), enumGISTaskPaused);//enumGISTaskQuered
        pNode->AddChild(new wxXmlNode(*pParameters));

        m_pConn->SendNetMessage(msg);
    }

    return Wait(nId, sMsg);
}
Exemple #5
0
wxGISEnumReturnType wxGISTaskManager::SetMaxTaskExec(const wxString &sCategory, int nMaxExecTaskCount, wxString & sMsg)
{
    long nId = wxNewId();

    wxNetMessage msg(enumGISNetCmdCmd, enumGISCmdSetParam, enumGISPriorityHigh, nId);
    wxXmlNode* pRootNode = msg.GetXMLRoot();
    if(pRootNode)
    {
        wxXmlNode* pNode = new wxXmlNode(pRootNode, wxXML_ELEMENT_NODE, wxT("cat"));
        pNode->AddAttribute(wxT("name"), sCategory);
        SetDecimalValue(pNode, wxT("cat_max_task_exec"), nMaxExecTaskCount);
        m_pConn->SendNetMessage(msg);
    }

    return Wait(nId, sMsg);
}
Exemple #6
0
wxGISEnumReturnType wxGISTaskManager::DeleteTask(int nTaskId, wxString & sMsg)
{
    long nId = wxNewId();
    wxNetMessage msg(enumGISNetCmdCmd, enumGISCmdStDel, enumGISPriorityHigh, nId);
    wxXmlNode* pRootNode = msg.GetXMLRoot();
    if(pRootNode)
    {
        wxXmlNode* pNode = new wxXmlNode(pRootNode, wxXML_ELEMENT_NODE, wxT("task"));
        wxGISTask* pTask = GetTask(nTaskId);
        pNode->AddAttribute(wxT("cat"), pTask->GetCategory());
        SetDecimalValue(pNode, wxT("id"), nTaskId);
        m_pConn->SendNetMessage(msg);
    }
    else
    {
        sMsg = wxString(_("Net message create failed"));
        return enumGISReturnFailed;
    }
    return Wait(nId, sMsg);
}
void wxGxContentView::Serialize(wxXmlNode* pRootNode, bool bStore)
{
	if(pRootNode == NULL)
		return;

	if(bStore)
	{
        if(pRootNode->HasAttribute(wxT("style")))
            pRootNode->DeleteAttribute(wxT("style"));
        SetDecimalValue(pRootNode, wxT("style"), m_current_style);
        if(pRootNode->HasAttribute(wxT("sort")))
            pRootNode->DeleteAttribute(wxT("sort"));
        SetBoolValue(pRootNode, wxT("sort"), m_bSortAsc);
        if(pRootNode->HasAttribute(wxT("sort_col")))
            pRootNode->DeleteAttribute(wxT("sort_col"));
        SetDecimalValue(pRootNode, wxT("sort_col"), m_currentSortCol);

        if(m_current_style == enumGISCVReport)
        {
            //store values
            m_anWidth.Clear();
            for (int i = 0; i < GetColumnCount(); ++i)
            {
                m_anWidth.Add( GetColumnWidth(i) );
            }
    #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
            m_anOrder = GetColumnsOrder();
    #endif
        }

        wxString sCols;
        for(size_t i = 0; i < m_anWidth.GetCount(); ++i)
        {
            sCols += wxString::Format(wxT("%d"), m_anWidth[i]);
            sCols += wxT("|");
        }
        if(pRootNode->HasAttribute(wxT("cols_width")))
            pRootNode->DeleteAttribute(wxT("cols_width"));
        pRootNode->AddAttribute(wxT("cols_width"), sCols);

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        wxString sOrd;
        for(size_t i = 0; i < m_anOrder.GetCount(); ++i)
        {
            sOrd += wxString::Format(wxT("%d"), m_anOrder[i]);
            sOrd += wxT("|");
        }

        if(pRootNode->HasAttribute(wxT("cols_order")))
            pRootNode->DeleteAttribute(wxT("cols_order"));
        pRootNode->AddAttribute(wxT("cols_order"), sOrd);
#endif

	}
	else
	{
		m_bSortAsc = GetBoolValue(pRootNode, wxT("sort"), true);
		m_currentSortCol = GetDecimalValue(pRootNode, wxT("sort_col"), 0);
		wxGISEnumContentsViewStyle style = (wxGISEnumContentsViewStyle)GetDecimalValue(pRootNode, wxT("style"), 0);
        //load col width
        wxString sCol = pRootNode->GetAttribute(wxT("cols_width"));
	    wxStringTokenizer tkz(sCol, wxString(wxT("|")), wxTOKEN_RET_EMPTY );
	    while ( tkz.HasMoreTokens() )
	    {
		    wxString token = tkz.GetNextToken();
		    //token.Replace(wxT("|"), wxT(""));
		    int nWidth = wxAtoi(token); //wxLIST_AUTOSIZE
            m_anWidth.Add(nWidth);
	    }

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        //load col order
        wxString sOrd = pRootNode->GetAttribute(wxT("cols_order"));
	    wxStringTokenizer tkz_ord(sOrd, wxString(wxT("|")), wxTOKEN_RET_EMPTY );
	    while ( tkz_ord.HasMoreTokens() )
	    {
		    wxString token = tkz_ord.GetNextToken();
		    //token.Replace(wxT("|"), wxT(""));
		    m_anOrder.Add( wxAtoi(token) );
	    }
#endif

        SetStyle(style);

        SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
		SortItems(GxObjectCVCompareFunction, (long)&sortdata);
	}
}