Diffstat (limited to 'noncore/securityplugins/notice') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/securityplugins/notice/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/securityplugins/notice/Makefile | 212 | ||||
-rw-r--r-- | noncore/securityplugins/notice/config.in | 4 | ||||
-rw-r--r-- | noncore/securityplugins/notice/notice.control | 11 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeConfigWidget.cpp | 81 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeConfigWidget.h | 71 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.cpp | 83 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.h | 62 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.pro | 17 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticepluginimpl.cpp | 28 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticepluginimpl.h | 61 |
11 files changed, 633 insertions, 0 deletions
diff --git a/noncore/securityplugins/notice/.cvsignore b/noncore/securityplugins/notice/.cvsignore new file mode 100644 index 0000000..a4e0e29 --- a/dev/null +++ b/noncore/securityplugins/notice/.cvsignore | |||
@@ -0,0 +1,3 @@ | |||
1 | .moc | ||
2 | .obj | ||
3 | Makefile | ||
diff --git a/noncore/securityplugins/notice/Makefile b/noncore/securityplugins/notice/Makefile new file mode 100644 index 0000000..6303951 --- a/dev/null +++ b/noncore/securityplugins/notice/Makefile | |||
@@ -0,0 +1,212 @@ | |||
1 | ############################################################################# | ||
2 | # Makefile for building: libmultiauthnoticeplugin.so.1.0.0 | ||
3 | # Generated by qmake (1.05a) (Qt 3.1.2) on: Mon Jun 14 11:00:20 2004 | ||
4 | # Project: noticeplugin.pro | ||
5 | # Template: lib | ||
6 | # Command: $(QMAKE) -o Makefile noticeplugin.pro | ||
7 | ############################################################################# | ||
8 | |||
9 | ####### Compiler, tools and options | ||
10 | |||
11 | CC = $(CCACHE) $(DISTCC) gcc | ||
12 | CXX = $(CCACHE) $(DISTCC) g++ | ||
13 | LEX = flex | ||
14 | YACC = yacc | ||
15 | CFLAGS = -pipe $(CFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 | ||
16 | CXXFLAGS = -pipe $(CFLAGS_EXTRA) -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA) -Wall -W -g -fPIC -DQT_COMPONENT_DEBUG=2 -DQT_DEBUG -DOPIE_NO_BUILTIN_SHUTDOWN -DUSE_FILE_NOTIFICATION -DOPIE_SOUND_FRAGMENT_SHIFT=16 | ||
17 | LEXFLAGS = | ||
18 | YACCFLAGS= -d | ||
19 | INCPATH = -I/opt/opie/mkspecs/qws/linux-generic-g++ -I. -I$(OPIEDIR)/include -I$(QTDIR)/include -I.moc/$(PLATFORM)/ | ||
20 | LINK = g++ | ||
21 | LFLAGS = $(LFLAGS_EXTRA) -Wl,-rpath-link,$(OPIEDIR)/lib -shared -Wl,-soname,libmultiauthnoticeplugin.so.1 -Wl,-rpath,/opt/opie/plugins/security | ||
22 | LIBS = $(SUBLIBS) -Wl,-rpath,$(QTDIR)/lib -L$(QTDIR)/lib $(LIBS_EXTRA) -lqpe -lopieui2 -L$(OPIEDIR)/lib -lqte | ||
23 | AR = ar cqs | ||
24 | RANLIB = | ||
25 | MOC = $(QTDIR)/bin/moc | ||
26 | UIC = $(QTDIR)/bin/uic | ||
27 | QMAKE = qmake | ||
28 | TAR = tar -cf | ||
29 | GZIP = gzip -9f | ||
30 | COPY = cp -f | ||
31 | COPY_FILE= $(COPY) -p | ||
32 | COPY_DIR = $(COPY) -pR | ||
33 | DEL_FILE = rm -f | ||
34 | SYMLINK = ln -sf | ||
35 | DEL_DIR = rmdir | ||
36 | MOVE = mv -f | ||
37 | PRO = noticeplugin.pro | ||
38 | CHK_DIR_EXISTS= | ||
39 | MKDIR = | ||
40 | |||
41 | ####### Output directory | ||
42 | |||
43 | OBJECTS_DIR = .obj/$(PLATFORM)/ | ||
44 | |||
45 | ####### Files | ||
46 | |||
47 | HEADERS = noticeplugin.h \ | ||
48 | noticepluginimpl.h \ | ||
49 | noticeConfigWidget.h | ||
50 | SOURCES = noticeplugin.cpp \ | ||
51 | noticepluginimpl.cpp \ | ||
52 | noticeConfigWidget.cpp | ||
53 | OBJECTS = .obj/$(PLATFORM)/noticeplugin.o \ | ||
54 | .obj/$(PLATFORM)/noticepluginimpl.o \ | ||
55 | .obj/$(PLATFORM)/noticeConfigWidget.o | ||
56 | FORMS = | ||
57 | UICDECLS = | ||
58 | UICIMPLS = | ||
59 | SRCMOC = .moc/$(PLATFORM)/moc_noticeConfigWidget.cpp | ||
60 | OBJMOC = .obj/$(PLATFORM)/moc_noticeConfigWidget.o | ||
61 | DIST = ../../../gen.pro \ | ||
62 | ../../../include.pro \ | ||
63 | noticeplugin.pro | ||
64 | QMAKE_TARGET = multiauthnoticeplugin | ||
65 | DESTDIR = $(OPIEDIR)/plugins/security/ | ||
66 | TARGET = libmultiauthnoticeplugin.so.1.0.0 | ||
67 | TARGETA= $(OPIEDIR)/plugins/security/libmultiauthnoticeplugin.a | ||
68 | TARGETD= libmultiauthnoticeplugin.so.1.0.0 | ||
69 | TARGET0= libmultiauthnoticeplugin.so | ||
70 | TARGET1= libmultiauthnoticeplugin.so.1 | ||
71 | TARGET2= libmultiauthnoticeplugin.so.1.0 | ||
72 | |||
73 | first: all | ||
74 | ####### Implicit rules | ||
75 | |||
76 | .SUFFIXES: .c .cpp .cc .cxx .C | ||
77 | |||
78 | .cpp.o: | ||
79 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
80 | |||
81 | .cc.o: | ||
82 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
83 | |||
84 | .cxx.o: | ||
85 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
86 | |||
87 | .C.o: | ||
88 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
89 | |||
90 | .c.o: | ||
91 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
92 | |||
93 | ####### Build rules | ||
94 | |||
95 | all: Makefile $(OPIEDIR)/plugins/security/$(TARGET) | ||
96 | |||
97 | $(OPIEDIR)/plugins/security/$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
98 | test -d $(OPIEDIR)/plugins/security/ || mkdir -p $(OPIEDIR)/plugins/security/ | ||
99 | -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) | ||
100 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
101 | -ln -s $(TARGET) $(TARGET0) | ||
102 | -ln -s $(TARGET) $(TARGET1) | ||
103 | -ln -s $(TARGET) $(TARGET2) | ||
104 | -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) | ||
105 | -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) | ||
106 | -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET1) | ||
107 | -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET2) | ||
108 | -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(OPIEDIR)/plugins/security/ | ||
109 | |||
110 | |||
111 | |||
112 | staticlib: $(TARGETA) | ||
113 | |||
114 | $(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) | ||
115 | -$(DEL_FILE) $(TARGETA) | ||
116 | $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) | ||
117 | |||
118 | mocables: $(SRCMOC) | ||
119 | |||
120 | $(MOC): | ||
121 | ( cd $(QTDIR)/src/moc ; $(MAKE) ) | ||
122 | |||
123 | Makefile: noticeplugin.pro /opt/opie/mkspecs/qws/linux-generic-g++/qmake.conf ../../../gen.pro \ | ||
124 | ../../../include.pro | ||
125 | $(QMAKE) -o Makefile noticeplugin.pro | ||
126 | qmake: | ||
127 | @$(QMAKE) -o Makefile noticeplugin.pro | ||
128 | |||
129 | dist: | ||
130 | @mkdir -p .obj/$(PLATFORM)/multiauthnoticeplugin && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .obj/$(PLATFORM)/multiauthnoticeplugin/ && ( cd `dirname .obj/$(PLATFORM)/multiauthnoticeplugin` && $(TAR) multiauthnoticeplugin.tar multiauthnoticeplugin && $(GZIP) multiauthnoticeplugin.tar ) && $(MOVE) `dirname .obj/$(PLATFORM)/multiauthnoticeplugin`/multiauthnoticeplugin.tar.gz . && $(DEL_FILE) -r .obj/$(PLATFORM)/multiauthnoticeplugin | ||
131 | |||
132 | mocclean: | ||
133 | -$(DEL_FILE) $(OBJMOC) | ||
134 | -$(DEL_FILE) $(SRCMOC) | ||
135 | |||
136 | uiclean: | ||
137 | |||
138 | yaccclean: | ||
139 | lexclean: | ||
140 | clean: mocclean | ||
141 | -$(DEL_FILE) $(OBJECTS) | ||
142 | -$(DEL_FILE) *~ core *.core | ||
143 | |||
144 | |||
145 | ####### Sub-libraries | ||
146 | |||
147 | distclean: clean | ||
148 | -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET) $(TARGET) | ||
149 | -$(DEL_FILE) $(OPIEDIR)/plugins/security/$(TARGET0) $(OPIEDIR)/plugins/security/$(TARGET1) $(OPIEDIR)/plugins/security/$(TARGET2) $(TARGETA) | ||
150 | |||
151 | |||
152 | lupdate: | ||
153 | lupdate -noobsolete $(PRO) | ||
154 | |||
155 | lrelease: | ||
156 | lrelease $(PRO) | ||
157 | |||
158 | ipk: | ||
159 | tmp=`mktemp -d /tmp/ipkg-opie.XXXXXXXXXX` && ( $(MAKE) INSTALL_ROOT="" install && ipkg-build ; rm -rf ; ) | ||
160 | |||
161 | opie-lupdate: | ||
162 | opie-lupdate $(PRO) | ||
163 | |||
164 | opie-lrelease: | ||
165 | opie-lrelease $(PRO) | ||
166 | |||
167 | messages: | ||
168 | xgettext -C -n -ktr -kQT_TRANSLATE_NOOP noticeplugin.h noticepluginimpl.h noticeConfigWidget.h noticeplugin.cpp noticepluginimpl.cpp noticeConfigWidget.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-tr.po' && xgettext -C -n -a noticeplugin.h noticepluginimpl.h noticeConfigWidget.h noticeplugin.cpp noticepluginimpl.cpp noticeConfigWidget.cpp -o '$(OPIEDIR)/messages-$(QMAKE_TARGET)-allstrings.po' | ||
169 | |||
170 | FORCE: | ||
171 | |||
172 | ####### Compile | ||
173 | |||
174 | .obj/$(PLATFORM)/noticeplugin.o: noticeplugin.cpp noticeplugin.h \ | ||
175 | noticeConfigWidget.h | ||
176 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/noticeplugin.o noticeplugin.cpp | ||
177 | |||
178 | .obj/$(PLATFORM)/noticepluginimpl.o: noticepluginimpl.cpp noticepluginimpl.h \ | ||
179 | noticeplugin.h \ | ||
180 | noticeConfigWidget.h | ||
181 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/noticepluginimpl.o noticepluginimpl.cpp | ||
182 | |||
183 | .obj/$(PLATFORM)/noticeConfigWidget.o: noticeConfigWidget.cpp noticeConfigWidget.h | ||
184 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/noticeConfigWidget.o noticeConfigWidget.cpp | ||
185 | |||
186 | .obj/$(PLATFORM)/moc_noticeConfigWidget.o: .moc/$(PLATFORM)/moc_noticeConfigWidget.cpp noticeConfigWidget.h | ||
187 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/$(PLATFORM)/moc_noticeConfigWidget.o .moc/$(PLATFORM)/moc_noticeConfigWidget.cpp | ||
188 | |||
189 | .moc/x86-linux/moc_noticeConfigWidget.cpp: $(MOC) noticeConfigWidget.h | ||
190 | $(MOC) noticeConfigWidget.h -o .moc/x86-linux/moc_noticeConfigWidget.cpp | ||
191 | |||
192 | ####### Install | ||
193 | |||
194 | install_target: | ||
195 | @$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" || $(MKDIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" | ||
196 | -$(COPY) "$(OPIEDIR)/plugins/security/$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" | ||
197 | -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" | ||
198 | -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" | ||
199 | -$(SYMLINK) "$(TARGET)" "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" | ||
200 | |||
201 | uninstall_target: | ||
202 | -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET)" | ||
203 | -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET0)" | ||
204 | -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET1)" | ||
205 | -$(DEL_FILE) "$(INSTALL_ROOT)$(OPIEDIR)/lib/$(TARGET2)" | ||
206 | -$(DEL_DIR) "$(INSTALL_ROOT)$(OPIEDIR)/lib/" | ||
207 | |||
208 | |||
209 | install: all install_target | ||
210 | |||
211 | uninstall: uninstall_target | ||
212 | |||
diff --git a/noncore/securityplugins/notice/config.in b/noncore/securityplugins/notice/config.in new file mode 100644 index 0000000..bfc649e --- a/dev/null +++ b/noncore/securityplugins/notice/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config MULTIAUTH_NOTICE | ||
2 | boolean "opie-multiauth-notice (Notice plugin for opie-multiauth)" | ||
3 | default "y" | ||
4 | depends SECURITY | ||
diff --git a/noncore/securityplugins/notice/notice.control b/noncore/securityplugins/notice/notice.control new file mode 100644 index 0000000..890e0c9 --- a/dev/null +++ b/noncore/securityplugins/notice/notice.control | |||
@@ -0,0 +1,11 @@ | |||
1 | Package: opie-multiauth-noticeplugin | ||
2 | Files: plugins/security/libmultiauthnoticeplugin.so* pics/security/noticeplugin.png pics/security/noticeplugin_small.png | ||
3 | Priority: optional | ||
4 | Section: opie/settings | ||
5 | Maintainer: Clement Seveillac <clement@nist.gov> | ||
6 | Architecture: arm | ||
7 | Version: 0.0.1.6 | ||
8 | Depends: opie-security | ||
9 | Description: Notice plugin for opie-security authentication. | ||
10 | It allows you to display, for example, a notice from your legal departement. | ||
11 | |||
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp new file mode 100644 index 0000000..e2c2d83 --- a/dev/null +++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp | |||
@@ -0,0 +1,81 @@ | |||
1 | #include "noticeConfigWidget.h" | ||
2 | |||
3 | #include <opie2/odebug.h> | ||
4 | |||
5 | #include <qwidget.h> | ||
6 | #include <qlayout.h> | ||
7 | #include <qlabel.h> | ||
8 | #include <qregexp.h> | ||
9 | #include <qgroupbox.h> | ||
10 | |||
11 | /// constructs the widget, filling the noticeMLE QMultiLineEdit with the "noticeText" entry | ||
12 | NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name) | ||
13 | { | ||
14 | QVBoxLayout *baseLayout = new QVBoxLayout( this); | ||
15 | baseLayout->setSpacing(11); | ||
16 | baseLayout->setMargin(6); | ||
17 | baseLayout->setAlignment( Qt::AlignTop ); | ||
18 | |||
19 | QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this); | ||
20 | baseLayout->addWidget(configBox); | ||
21 | QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() ); | ||
22 | |||
23 | QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox); | ||
24 | boxLayout->addWidget(comment1); | ||
25 | |||
26 | // Set the multilineedit box text to getNoticeText() | ||
27 | noticeMLE = new QMultiLineEdit(configBox, "notice text"); | ||
28 | noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth); | ||
29 | noticeMLE->setFocus(); | ||
30 | noticeMLE->setText(getNoticeText()); | ||
31 | boxLayout->addWidget(noticeMLE); | ||
32 | |||
33 | resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" ); | ||
34 | connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() )); | ||
35 | boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter); | ||
36 | |||
37 | QLabel * comment2 = new QLabel("<p>" + tr("Note: you can use HTML tags to improve its layout (example: text between <em> and </em> will be <em>emphasized</em>)") + "</p>", configBox); | ||
38 | boxLayout->addWidget(comment2); | ||
39 | |||
40 | } | ||
41 | |||
42 | /// nothing to do | ||
43 | NoticeConfigWidget::~NoticeConfigWidget() | ||
44 | {} | ||
45 | |||
46 | /// write the notice text in the multiauth.conf Config file | ||
47 | void NoticeConfigWidget::writeConfig() | ||
48 | { | ||
49 | if ( noticeMLE->edited() ) { | ||
50 | odebug << "writing new notice text in Security.conf" << oendl; | ||
51 | setNoticeText(noticeMLE->text()); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | /// reset the notice text to the hard-coded example defaultNoticeText | ||
56 | void NoticeConfigWidget::resetNotice() | ||
57 | { | ||
58 | noticeMLE->setText(defaultNoticeText); | ||
59 | } | ||
60 | |||
61 | /// get the notice text from the config file (with true new lines) | ||
62 | /** | ||
63 | * if no text has been defined yet returns defaultNoticeText | ||
64 | */ | ||
65 | QString NoticeConfigWidget::getNoticeText() { | ||
66 | m_config = new Config("Security"); | ||
67 | m_config->setGroup("NoticePlugin"); | ||
68 | // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp | ||
69 | QString noticeText = m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" ); | ||
70 | delete m_config; | ||
71 | return noticeText; | ||
72 | } | ||
73 | |||
74 | /// set the notice text in our m_config config file (escaping new lines) | ||
75 | void NoticeConfigWidget::setNoticeText(QString noticeText) { | ||
76 | m_config = new Config("Security"); | ||
77 | m_config->setGroup("NoticePlugin"); | ||
78 | // since Config files do not allow true newlines, we replace them with litteral "\n" | ||
79 | m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" )); | ||
80 | delete m_config; | ||
81 | } | ||
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.h b/noncore/securityplugins/notice/noticeConfigWidget.h new file mode 100644 index 0000000..69f15bf --- a/dev/null +++ b/noncore/securityplugins/notice/noticeConfigWidget.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /** | ||
2 | * \file noticeConfigWidget.h | ||
3 | * \brief Notice plugin configuration widget | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef NOTICECONFIGWIDGET_H | ||
35 | #define NOTICECONFIGWIDGET_H | ||
36 | |||
37 | #include <qpushbutton.h> | ||
38 | #include <qmultilineedit.h> | ||
39 | #include <qpe/config.h> | ||
40 | |||
41 | #include <opie2/multiauthconfigwidget.h> | ||
42 | |||
43 | static char defaultNoticeText [] = "<h2>NOTICE TO USERS</h2>\n" | ||
44 | "<p>This is a private computer system and is the property of " | ||
45 | "the company XXX / Mr or Ms X. It is for authorized " | ||
46 | "use only. Users have no expectation of privacy.</p>\n" | ||
47 | "<p><strong>Unauthorized or improper use of this system may result in " | ||
48 | "disciplinary action and civil and criminal penalties. <em>By continuing to use " | ||
49 | "this system you indicate your awareness of and consent to these " | ||
50 | "terms. LOG OFF IMMEDIATELY if you do not agree to them.</em></strong></p>"; | ||
51 | |||
52 | class NoticeConfigWidget : public MultiauthConfigWidget { | ||
53 | |||
54 | Q_OBJECT | ||
55 | |||
56 | public: | ||
57 | NoticeConfigWidget(QWidget* parent, const char* name); | ||
58 | virtual ~NoticeConfigWidget(); | ||
59 | virtual void writeConfig(); | ||
60 | private: | ||
61 | QMultiLineEdit * noticeMLE; | ||
62 | QPushButton * resetNoticeButton; | ||
63 | private slots: | ||
64 | void resetNotice(); | ||
65 | private: | ||
66 | Config * m_config; | ||
67 | QString getNoticeText(); | ||
68 | void setNoticeText(QString noticeText); | ||
69 | }; | ||
70 | |||
71 | #endif // NOTICECONFIGWIDGET_H | ||
diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp new file mode 100644 index 0000000..f7d41ab --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.cpp | |||
@@ -0,0 +1,83 @@ | |||
1 | #include "noticeplugin.h" | ||
2 | |||
3 | #include <opie2/oapplication.h> | ||
4 | |||
5 | #include <qmessagebox.h> | ||
6 | #include <qregexp.h> | ||
7 | |||
8 | /// creates and initializes the m_config Config object | ||
9 | NoticePlugin::NoticePlugin() : MultiauthPluginObject(), noticeW(0) { | ||
10 | m_config = new Config("Security"); | ||
11 | m_config->setGroup("NoticePlugin"); | ||
12 | } | ||
13 | |||
14 | /// deletes the m_config Config object and noticeW if necessary | ||
15 | NoticePlugin::~NoticePlugin() { | ||
16 | delete m_config; | ||
17 | if (noticeW != 0) | ||
18 | delete noticeW; | ||
19 | } | ||
20 | |||
21 | /// Simply return its name (Notice plugin) | ||
22 | QString NoticePlugin::pluginName() const { | ||
23 | return "Notice plugin"; | ||
24 | } | ||
25 | |||
26 | /// return the Notice widget configuration widget | ||
27 | /** | ||
28 | * \return noticeW, the NoticeConfigWidget | ||
29 | */ | ||
30 | MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) { | ||
31 | if (noticeW == 0) | ||
32 | noticeW = new NoticeConfigWidget(parent, "Notice configuration widget"); | ||
33 | return noticeW; | ||
34 | } | ||
35 | |||
36 | /// return the path of the small tab icon | ||
37 | QString NoticePlugin::pixmapNameConfig() const { | ||
38 | return "security/noticeplugin_small"; | ||
39 | } | ||
40 | |||
41 | /// return the path of the big icon for the active/order checklist | ||
42 | QString NoticePlugin::pixmapNameWidget() const { | ||
43 | return "security/noticeplugin"; | ||
44 | } | ||
45 | |||
46 | /// Displays the configured message and an 'Accept' button | ||
47 | /** | ||
48 | * \return the outcome code of this authentication (can be only success) | ||
49 | */ | ||
50 | int NoticePlugin::authenticate() { | ||
51 | QMessageBox noticeDialog("Notice plugin", | ||
52 | getNoticeText(), | ||
53 | QMessageBox::Warning, | ||
54 | QMessageBox::Yes, | ||
55 | 0, | ||
56 | 0, | ||
57 | 0, | ||
58 | "notice plugin dialog", | ||
59 | true, | ||
60 | Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop); | ||
61 | |||
62 | noticeDialog.setButtonText(QMessageBox::Yes, "I accept"); | ||
63 | |||
64 | QRect desk = oApp->desktop()->geometry(); | ||
65 | noticeDialog.setGeometry( 0, 0, desk.width(), desk.height() ); | ||
66 | |||
67 | switch (noticeDialog.exec()) | ||
68 | { | ||
69 | case QMessageBox::Yes: | ||
70 | return MultiauthPluginObject::Success; | ||
71 | } | ||
72 | return 255; //should not be returned anyway | ||
73 | } | ||
74 | |||
75 | /// get the notice text from our m_config config file (with true new lines) | ||
76 | /** | ||
77 | * if no text has been defined yet returns defaultNoticeText | ||
78 | */ | ||
79 | QString NoticePlugin::getNoticeText() { | ||
80 | // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp | ||
81 | return m_config->readEntry("noticeText", defaultNoticeText).replace( QRegExp("\\\\n"), "\n" ); | ||
82 | } | ||
83 | |||
diff --git a/noncore/securityplugins/notice/noticeplugin.h b/noncore/securityplugins/notice/noticeplugin.h new file mode 100644 index 0000000..e01cb93 --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /** | ||
2 | * \file noticeplugin.h | ||
3 | * \brief Standard Opie multiauth plugin definition | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef NOTICE_PLUGIN_H | ||
35 | #define NOTICE_PLUGIN_H | ||
36 | |||
37 | #include <qstring.h> | ||
38 | #include <qpe/config.h> | ||
39 | #include <opie2/multiauthplugininterface.h> | ||
40 | #include "noticeConfigWidget.h" | ||
41 | |||
42 | /// Multi-authentication plugin, having the user accept a (legal, etc.) notice text. | ||
43 | /** | ||
44 | * The plugin itself, implementing the main authenticate() function. | ||
45 | */ | ||
46 | class NoticePlugin : public MultiauthPluginObject { | ||
47 | |||
48 | public: | ||
49 | NoticePlugin(); | ||
50 | virtual ~NoticePlugin(); | ||
51 | int authenticate(); | ||
52 | MultiauthConfigWidget * configWidget(QWidget * parent); | ||
53 | QString pixmapNameConfig() const; | ||
54 | QString pixmapNameWidget() const; | ||
55 | QString pluginName() const; | ||
56 | private: | ||
57 | NoticeConfigWidget * noticeW; | ||
58 | Config * m_config; | ||
59 | QString getNoticeText(); | ||
60 | }; | ||
61 | |||
62 | #endif | ||
diff --git a/noncore/securityplugins/notice/noticeplugin.pro b/noncore/securityplugins/notice/noticeplugin.pro new file mode 100644 index 0000000..51532a2 --- a/dev/null +++ b/noncore/securityplugins/notice/noticeplugin.pro | |||
@@ -0,0 +1,17 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on | ||
3 | |||
4 | HEADERS = noticeplugin.h noticepluginimpl.h noticeConfigWidget.h | ||
5 | |||
6 | SOURCES = noticeplugin.cpp noticepluginimpl.cpp noticeConfigWidget.cpp | ||
7 | |||
8 | |||
9 | INCLUDEPATH+= $(OPIEDIR)/include | ||
10 | DEPENDPATH+= | ||
11 | |||
12 | LIBS += -lqpe -lopieui2 | ||
13 | |||
14 | DESTDIR = $(OPIEDIR)/plugins/security | ||
15 | TARGET = multiauthnoticeplugin | ||
16 | |||
17 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/securityplugins/notice/noticepluginimpl.cpp b/noncore/securityplugins/notice/noticepluginimpl.cpp new file mode 100644 index 0000000..34e3cfc --- a/dev/null +++ b/noncore/securityplugins/notice/noticepluginimpl.cpp | |||
@@ -0,0 +1,28 @@ | |||
1 | #include "noticepluginimpl.h" | ||
2 | |||
3 | NoticePluginImpl::NoticePluginImpl() { | ||
4 | noticePlugin = new NoticePlugin(); | ||
5 | } | ||
6 | |||
7 | NoticePluginImpl::~NoticePluginImpl() { | ||
8 | delete noticePlugin; | ||
9 | } | ||
10 | |||
11 | MultiauthPluginObject* NoticePluginImpl::plugin() { | ||
12 | return noticePlugin; | ||
13 | } | ||
14 | |||
15 | Q_EXPORT_INTERFACE() { | ||
16 | Q_CREATE_INSTANCE( NoticePluginImpl ) | ||
17 | } | ||
18 | |||
19 | QRESULT NoticePluginImpl::queryInterface( const QUuid & uuid, QUnknownInterface **iface ) { | ||
20 | *iface = 0; | ||
21 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MultiauthPluginInterface ) ) { | ||
22 | *iface = this, (*iface)->addRef(); | ||
23 | } else { | ||
24 | return QE_NOINTERFACE; | ||
25 | } | ||
26 | return QS_OK; | ||
27 | |||
28 | } | ||
diff --git a/noncore/securityplugins/notice/noticepluginimpl.h b/noncore/securityplugins/notice/noticepluginimpl.h new file mode 100644 index 0000000..b2a1140 --- a/dev/null +++ b/noncore/securityplugins/notice/noticepluginimpl.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /** | ||
2 | * \file noticepluginimpl.h | ||
3 | * \brief Standard Opie multiauth plugin definition | ||
4 | * \author Clément Séveillac (clement . seveillac (at) via . ecp . fr) | ||
5 | */ | ||
6 | /* | ||
7 | =. This file is part of the Opie Project | ||
8 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This library is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This library is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef NOTICE_PLUGIN_IMPL | ||
35 | #define NOTICE_PLUGIN_IMPL | ||
36 | |||
37 | #include "noticeplugin.h" | ||
38 | |||
39 | /** | ||
40 | * \brief Standard multiauth plugin class | ||
41 | */ | ||
42 | class NoticePluginImpl : public MultiauthPluginInterface{ | ||
43 | |||
44 | public: | ||
45 | NoticePluginImpl(); | ||
46 | virtual ~NoticePluginImpl(); | ||
47 | |||
48 | QRESULT queryInterface( const QUuid &, QUnknownInterface** ); | ||
49 | /// defines standard addRef() and release() functions | ||
50 | Q_REFCOUNT; | ||
51 | |||
52 | virtual MultiauthPluginObject *plugin(); | ||
53 | |||
54 | private: | ||
55 | /// the plugin itself | ||
56 | NoticePlugin *noticePlugin; | ||
57 | ulong ref; | ||
58 | }; | ||
59 | |||
60 | #endif | ||
61 | |||