source: eviacam/trunk/fuentes/src/cautostart.cpp @ 567

Last change on this file since 567 was 567, checked in by mabarracus, 4 years ago

updated sources to version 2.0.3

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// Name:        cautostart.cpp
3// Purpose: 
4// Author:      Cesar Mauri Loba (cesar at crea-si dot com)
5// Modified by:
6// Created:     07/07/2010
7// Copyright:   (C) 2008 Cesar Mauri Loba - CREA Software Systems
8//
9//  This program is free software: you can redistribute it and/or modify
10//  it under the terms of the GNU General Public License as published by
11//  the Free Software Foundation, either version 3 of the License, or
12//  (at your option) any later version.
13//
14//  This program is distributed in the hope that it will be useful,
15//  but WITHOUT ANY WARRANTY; without even the implied warranty of
16//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17//  GNU General Public License for more details.
18//
19//  You should have received a copy of the GNU General Public License
20//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21/////////////////////////////////////////////////////////////////////////////
22#include "cautostart.h"
23#include <wx/string.h>
24#include <wx/stdpaths.h>
25#include <wx/utils.h>
26
27#include "paths.h"
28
29CAutostart::CAutostart(wxString fileName)
30{
31        m_fileName = fileName;
32}
33
34CAutostart::~CAutostart()
35{
36}
37
38bool CAutostart::IsEnabled()
39{
40#if defined(__WXGTK__)
41        wxString path;
42
43        if (!wxGetEnv(wxT("XDG_CONFIG_HOME"), &path)) {
44                path = wxStandardPaths::Get().GetUserConfigDir() + wxT("/.config/autostart/");
45        }
46
47        return wxFileExists(path + m_fileName);
48#else
49        assert (false); // Win: not yet implemented
50        return false;
51#endif
52}
53
54
55void CAutostart::Enable(bool value)
56{
57#if defined(__WXGTK__)
58        wxString pathIn;
59        wxString pathOut;
60
61        pathIn = eviacam::GetDataDir()  + wxT("/") + m_fileName;
62        if (!wxGetEnv(wxT("XDG_CONFIG_HOME"), &pathOut)) {
63                pathOut = wxStandardPaths::Get().GetUserConfigDir() + wxT("/.config");
64                if (!wxDirExists(pathOut))
65                        wxMkdir(pathOut, 0777);
66                pathOut += wxT("/autostart/");
67        }
68       
69        if (value) {
70                if (!wxDirExists(pathOut))
71                        wxMkdir(pathOut, 0777);
72                wxCopyFile(pathIn, pathOut + m_fileName, false);
73        } else {
74                wxRemoveFile(pathOut + m_fileName);
75        }
76#else
77        assert (false);         // Not yet implemented
78        wxUnusedVar(value);
79#endif
80}
81
Note: See TracBrowser for help on using the repository browser.