~mc-return/compiz/compiz.merge-src-screen.cpp-improvements

« back to all changes in this revision

Viewing changes to plugins/ini.h

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2008 Danny Baumann
3
 
 *
4
 
 * Permission to use, copy, modify, distribute, and sell this software
5
 
 * and its documentation for any purpose is hereby granted without
6
 
 * fee, provided that the above copyright notice appear in all copies
7
 
 * and that both that copyright notice and this permission notice
8
 
 * appear in supporting documentation, and that the name of
9
 
 * Danny Baumann not be used in advertising or publicity pertaining to
10
 
 * distribution of the software without specific, written prior permission.
11
 
 * Danny Baumann makes no representations about the suitability of this
12
 
 * software for any purpose. It is provided "as is" without express or
13
 
 * implied warranty.
14
 
 *
15
 
 * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
 
 * NO EVENT SHALL DANNY BAUMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
 
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
 
 *
23
 
 * Author: Danny Baumann <dannybaumann@web.de>
24
 
 */
25
 
 
26
 
#include <stdio.h>
27
 
#include <stdlib.h>
28
 
#include <sys/stat.h>
29
 
 
30
 
#include <iostream>
31
 
#include <fstream>
32
 
 
33
 
#include <core/core.h>
34
 
#include <core/privatehandler.h>
35
 
 
36
 
#define HOME_OPTIONDIR     ".compiz/options"
37
 
#define CORE_NAME           "general"
38
 
#define FILE_SUFFIX         ".conf"
39
 
 
40
 
class IniScreen :
41
 
    public ScreenInterface,
42
 
    public PrivateHandler<IniScreen, CompScreen>
43
 
{
44
 
    public:
45
 
        IniScreen (CompScreen *screen);
46
 
        ~IniScreen ();
47
 
 
48
 
        bool initPluginForScreen (CompPlugin *p);
49
 
        bool setOptionForPlugin (const char        *plugin,
50
 
                                 const char        *name,
51
 
                                 CompOption::Value &v);
52
 
 
53
 
        void updateDirectoryWatch (const CompString&);
54
 
 
55
 
    private:
56
 
        CompFileWatchHandle directoryWatchHandle;
57
 
 
58
 
        void fileChanged (const char *name);
59
 
 
60
 
        bool blockWrites;
61
 
 
62
 
    public:
63
 
        static CompString getHomeDir ();
64
 
        static bool createDir (const CompString& path);
65
 
};
66
 
 
67
 
class IniPluginVTable :
68
 
    public CompPlugin::VTableForScreen<IniScreen>
69
 
{
70
 
    public:
71
 
 
72
 
        bool init ();
73
 
};
74
 
 
75
 
class IniFile
76
 
{
77
 
    public:
78
 
        IniFile (CompPlugin *p);
79
 
        ~IniFile ();
80
 
 
81
 
        void load ();
82
 
        void save ();
83
 
 
84
 
    private:
85
 
        CompPlugin *plugin;
86
 
        CompString filePath;
87
 
 
88
 
        std::fstream optionFile;
89
 
 
90
 
        bool open (bool write);
91
 
 
92
 
        CompString optionValueToString (CompOption::Value &value,
93
 
                                        CompOption::Type  type);
94
 
        CompString optionToString (CompOption &option,
95
 
                                   bool       &valid);
96
 
        bool stringToOption (CompOption *option,
97
 
                             CompString &valueString);
98
 
        bool stringToOptionValue (CompString        &string,
99
 
                                  CompOption::Type  type,
100
 
                                  CompOption::Value &value);
101
 
 
102
 
        bool validItemType (CompOption::Type type);
103
 
        bool validListItemType (CompOption::Type type);
104
 
};
105
 
 
106