summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-11-06 04:50:40 (UTC)
committer kergoth <kergoth>2002-11-06 04:50:40 (UTC)
commit21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f (patch) (unidiff)
treebbe53dd1f3749541be4f1616f20d9a0d9ee6ea0b
parentac1509552bf764ff136690e0e7014d37a59d073e (diff)
downloadopie-21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f.zip
opie-21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f.tar.gz
opie-21f27ec4a1f18321ac00d28d93cb1cb7dc957d1f.tar.bz2
Changing sharp define. if someone doesnt like it, let me know :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configs/linux-sharp-g++-shared2
-rw-r--r--configs/linux-sharp-g++-shared-debug2
-rw-r--r--configs/linux-sharp-g++-static2
-rw-r--r--configs/linux-sharp-g++-static-debug2
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp2
-rw-r--r--core/launcher/desktop.cpp2
-rw-r--r--core/launcher/main.cpp2
-rw-r--r--core/launcher/shutdownimpl.cpp2
-rw-r--r--core/launcher/taskbar.cpp4
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp2
-rw-r--r--library/alarmserver.cpp2
-rw-r--r--library/power.cpp4
-rw-r--r--library/storage.cpp2
-rw-r--r--qt/qte233-for-opie091-keyboard.patch4
14 files changed, 17 insertions, 17 deletions
diff --git a/configs/linux-sharp-g++-shared b/configs/linux-sharp-g++-shared
index 9c1dd03..862ee34 100644
--- a/configs/linux-sharp-g++-shared
+++ b/configs/linux-sharp-g++-shared
@@ -1,94 +1,94 @@
1# Compiling 1# Compiling
2 INTERFACE_DECL_PATH = . 2 INTERFACE_DECL_PATH = .
3 SYSCONF_CXX = arm-linux-g++ 3 SYSCONF_CXX = arm-linux-g++
4 SYSCONF_CC = arm-linux-gcc 4 SYSCONF_CC = arm-linux-gcc
5 DASHCROSS = -arm 5 DASHCROSS = -arm
6 6
7# Compiling with support libraries 7# Compiling with support libraries
8 SYSCONF_CXXFLAGS_X11= 8 SYSCONF_CXXFLAGS_X11=
9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include 9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include 10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include
11 11
12# Compiling YACC output 12# Compiling YACC output
13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses 13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
14 14
15# Linking with support libraries 15# Linking with support libraries
16 SYSCONF_RPATH_X11= 16 SYSCONF_RPATH_X11=
17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib 17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib
18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib 18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib
19 19
20# Linking with support libraries 20# Linking with support libraries
21# X11 21# X11
22 SYSCONF_LFLAGS_X11= 22 SYSCONF_LFLAGS_X11=
23 SYSCONF_LIBS_X11= 23 SYSCONF_LIBS_X11=
24# Qt, Qt+OpenGL 24# Qt, Qt+OpenGL
25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib 25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) 26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX)
27 SYSCONF_LIBS_QT_OPENGL= 27 SYSCONF_LIBS_QT_OPENGL=
28# OpenGL 28# OpenGL
29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib 29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib
30 SYSCONF_LIBS_OPENGL= 30 SYSCONF_LIBS_OPENGL=
31# Yacc 31# Yacc
32 SYSCONF_LIBS_YACC= 32 SYSCONF_LIBS_YACC=
33 33
34# Linking applications 34# Linking applications
35 SYSCONF_LINK = arm-linux-gcc 35 SYSCONF_LINK = arm-linux-gcc
36 SYSCONF_LFLAGS = 36 SYSCONF_LFLAGS =
37 SYSCONF_LIBS = 37 SYSCONF_LIBS =
38 38
39# Link flags for shared objects 39# Link flags for shared objects
40 SYSCONF_LFLAGS_SHOBJ= -shared 40 SYSCONF_LFLAGS_SHOBJ= -shared
41 41
42# Flags for threading 42# Flags for threading
43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT 43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT 44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
45 SYSCONF_LFLAGS_THREAD= 45 SYSCONF_LFLAGS_THREAD=
46 SYSCONF_LIBS_THREAD= -lpthread 46 SYSCONF_LIBS_THREAD= -lpthread
47 47
48# Meta-object compiler 48# Meta-object compiler
49 SYSCONF_MOC = $(QTDIR)/bin/moc 49 SYSCONF_MOC = $(QTDIR)/bin/moc
50 50
51# UI compiler 51# UI compiler
52 SYSCONF_UIC = $(QTDIR)/bin/uic 52 SYSCONF_UIC = $(QTDIR)/bin/uic
53 53
54# Linking shared libraries 54# Linking shared libraries
55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
56# - Place target in $(DESTDIR) - which has a trailing / 56# - Place target in $(DESTDIR) - which has a trailing /
57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) 57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
58# 58#
59 SYSCONF_LINK_SHLIB= arm-linux-gcc 59 SYSCONF_LINK_SHLIB= arm-linux-gcc
60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) 60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ 61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ 62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
63 $(OBJECTS) $(OBJMOC) $(LIBS) && \ 63 $(OBJECTS) $(OBJMOC) $(LIBS) && \
64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ 64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
65 cd $(DESTDIR) && \ 65 cd $(DESTDIR) && \
66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ 66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ 67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ 68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) 69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
70 70
71# Linking static libraries 71# Linking static libraries
72# - Build the $(TARGET) library, eg. lib$(TARGET).a 72# - Build the $(TARGET) library, eg. lib$(TARGET).a
73# - Place target in $(DESTDIR) - which has a trailing / 73# - Place target in $(DESTDIR) - which has a trailing /
74# 74#
75 SYSCONF_AR = arm-linux-ar cqs 75 SYSCONF_AR = arm-linux-ar cqs
76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a 76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ 77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) 78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
79# Compiling application source 79# Compiling application source
80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W 80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_SHARP -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W
81 SYSCONF_CFLAGS = -pipe -O2 -Wall -W 81 SYSCONF_CFLAGS = -pipe -O2 -Wall -W
82# Default link type (static linking is still be used where required) 82# Default link type (static linking is still be used where required)
83 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED) 83 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED)
84 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED) 84 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED)
85# Compiling library source 85# Compiling library source
86 SYSCONF_CXXFLAGS_LIB= -fPIC 86 SYSCONF_CXXFLAGS_LIB= -fPIC
87 SYSCONF_CFLAGS_LIB= -fPIC 87 SYSCONF_CFLAGS_LIB= -fPIC
88# Compiling shared-object source 88# Compiling shared-object source
89 SYSCONF_CXXFLAGS_SHOBJ= -fPIC 89 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
90 SYSCONF_CFLAGS_SHOBJ= -fPIC 90 SYSCONF_CFLAGS_SHOBJ= -fPIC
91# Linking Qt 91# Linking Qt
92 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) 92 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
93# Linking Qt applications 93# Linking Qt applications
94 SYSCONF_LIBS_QTAPP= 94 SYSCONF_LIBS_QTAPP=
diff --git a/configs/linux-sharp-g++-shared-debug b/configs/linux-sharp-g++-shared-debug
index 810eef5..5e7819c 100644
--- a/configs/linux-sharp-g++-shared-debug
+++ b/configs/linux-sharp-g++-shared-debug
@@ -1,94 +1,94 @@
1# Compiling 1# Compiling
2 INTERFACE_DECL_PATH = . 2 INTERFACE_DECL_PATH = .
3 SYSCONF_CXX = arm-linux-g++ 3 SYSCONF_CXX = arm-linux-g++
4 SYSCONF_CC = arm-linux-gcc 4 SYSCONF_CC = arm-linux-gcc
5 DASHCROSS = -arm 5 DASHCROSS = -arm
6 6
7# Compiling with support libraries 7# Compiling with support libraries
8 SYSCONF_CXXFLAGS_X11= 8 SYSCONF_CXXFLAGS_X11=
9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include 9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include 10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include
11 11
12# Compiling YACC output 12# Compiling YACC output
13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses 13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
14 14
15# Linking with support libraries 15# Linking with support libraries
16 SYSCONF_RPATH_X11= 16 SYSCONF_RPATH_X11=
17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib 17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib
18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib 18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib
19 19
20# Linking with support libraries 20# Linking with support libraries
21# X11 21# X11
22 SYSCONF_LFLAGS_X11= 22 SYSCONF_LFLAGS_X11=
23 SYSCONF_LIBS_X11= 23 SYSCONF_LIBS_X11=
24# Qt, Qt+OpenGL 24# Qt, Qt+OpenGL
25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib 25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) 26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX)
27 SYSCONF_LIBS_QT_OPENGL= 27 SYSCONF_LIBS_QT_OPENGL=
28# OpenGL 28# OpenGL
29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib 29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib
30 SYSCONF_LIBS_OPENGL= 30 SYSCONF_LIBS_OPENGL=
31# Yacc 31# Yacc
32 SYSCONF_LIBS_YACC= 32 SYSCONF_LIBS_YACC=
33 33
34# Linking applications 34# Linking applications
35 SYSCONF_LINK = arm-linux-gcc 35 SYSCONF_LINK = arm-linux-gcc
36 SYSCONF_LFLAGS = 36 SYSCONF_LFLAGS =
37 SYSCONF_LIBS = 37 SYSCONF_LIBS =
38 38
39# Link flags for shared objects 39# Link flags for shared objects
40 SYSCONF_LFLAGS_SHOBJ= -shared 40 SYSCONF_LFLAGS_SHOBJ= -shared
41 41
42# Flags for threading 42# Flags for threading
43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT 43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT 44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
45 SYSCONF_LFLAGS_THREAD= 45 SYSCONF_LFLAGS_THREAD=
46 SYSCONF_LIBS_THREAD= -lpthread 46 SYSCONF_LIBS_THREAD= -lpthread
47 47
48# Meta-object compiler 48# Meta-object compiler
49 SYSCONF_MOC = $(QTDIR)/bin/moc 49 SYSCONF_MOC = $(QTDIR)/bin/moc
50 50
51# UI compiler 51# UI compiler
52 SYSCONF_UIC = $(QTDIR)/bin/uic 52 SYSCONF_UIC = $(QTDIR)/bin/uic
53 53
54# Linking shared libraries 54# Linking shared libraries
55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
56# - Place target in $(DESTDIR) - which has a trailing / 56# - Place target in $(DESTDIR) - which has a trailing /
57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) 57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
58# 58#
59 SYSCONF_LINK_SHLIB= arm-linux-gcc 59 SYSCONF_LINK_SHLIB= arm-linux-gcc
60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) 60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ 61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ 62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
63 $(OBJECTS) $(OBJMOC) $(LIBS) && \ 63 $(OBJECTS) $(OBJMOC) $(LIBS) && \
64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ 64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
65 cd $(DESTDIR) && \ 65 cd $(DESTDIR) && \
66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ 66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ 67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ 68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) 69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
70 70
71# Linking static libraries 71# Linking static libraries
72# - Build the $(TARGET) library, eg. lib$(TARGET).a 72# - Build the $(TARGET) library, eg. lib$(TARGET).a
73# - Place target in $(DESTDIR) - which has a trailing / 73# - Place target in $(DESTDIR) - which has a trailing /
74# 74#
75 SYSCONF_AR = arm-linux-ar cqs 75 SYSCONF_AR = arm-linux-ar cqs
76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a 76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ 77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) 78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
79# Compiling application source 79# Compiling application source
80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -fno-exceptions -fno-rtti -g -Wall -W 80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_SHARP -DQWS -fno-exceptions -fno-rtti -g -Wall -W
81 SYSCONF_CFLAGS = -pipe -g -Wall -W 81 SYSCONF_CFLAGS = -pipe -g -Wall -W
82# Default link type (static linking is still be used where required) 82# Default link type (static linking is still be used where required)
83 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED) 83 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_SHARED)
84 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED) 84 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_SHARED)
85# Compiling library source 85# Compiling library source
86 SYSCONF_CXXFLAGS_LIB= -fPIC 86 SYSCONF_CXXFLAGS_LIB= -fPIC
87 SYSCONF_CFLAGS_LIB= -fPIC 87 SYSCONF_CFLAGS_LIB= -fPIC
88# Compiling shared-object source 88# Compiling shared-object source
89 SYSCONF_CXXFLAGS_SHOBJ= -fPIC 89 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
90 SYSCONF_CFLAGS_SHOBJ= -fPIC 90 SYSCONF_CFLAGS_SHOBJ= -fPIC
91# Linking Qt 91# Linking Qt
92 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) 92 SYSCONF_LIBS_QTLIB= $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
93# Linking Qt applications 93# Linking Qt applications
94 SYSCONF_LIBS_QTAPP= 94 SYSCONF_LIBS_QTAPP=
diff --git a/configs/linux-sharp-g++-static b/configs/linux-sharp-g++-static
index 15e4c7f..22d3d04 100644
--- a/configs/linux-sharp-g++-static
+++ b/configs/linux-sharp-g++-static
@@ -1,93 +1,93 @@
1# Compiling 1# Compiling
2 INTERFACE_DECL_PATH = . 2 INTERFACE_DECL_PATH = .
3 SYSCONF_CXX = arm-linux-g++ 3 SYSCONF_CXX = arm-linux-g++
4 SYSCONF_CC = arm-linux-gcc 4 SYSCONF_CC = arm-linux-gcc
5 DASHCROSS = -arm 5 DASHCROSS = -arm
6 6
7# Compiling with support libraries 7# Compiling with support libraries
8 SYSCONF_CXXFLAGS_X11= 8 SYSCONF_CXXFLAGS_X11=
9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include 9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include 10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include
11 11
12# Compiling YACC output 12# Compiling YACC output
13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses 13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
14 14
15# Linking with support libraries 15# Linking with support libraries
16 SYSCONF_RPATH_X11= 16 SYSCONF_RPATH_X11=
17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib 17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib
18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib 18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib
19 19
20# Linking with support libraries 20# Linking with support libraries
21# X11 21# X11
22 SYSCONF_LFLAGS_X11= 22 SYSCONF_LFLAGS_X11=
23 SYSCONF_LIBS_X11= 23 SYSCONF_LIBS_X11=
24# Qt, Qt+OpenGL 24# Qt, Qt+OpenGL
25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib 25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) 26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX)
27 SYSCONF_LIBS_QT_OPENGL= 27 SYSCONF_LIBS_QT_OPENGL=
28# OpenGL 28# OpenGL
29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib 29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib
30 SYSCONF_LIBS_OPENGL= 30 SYSCONF_LIBS_OPENGL=
31# Yacc 31# Yacc
32 SYSCONF_LIBS_YACC= 32 SYSCONF_LIBS_YACC=
33 33
34# Linking applications 34# Linking applications
35 SYSCONF_LINK = arm-linux-gcc 35 SYSCONF_LINK = arm-linux-gcc
36 SYSCONF_LFLAGS = 36 SYSCONF_LFLAGS =
37 SYSCONF_LIBS = 37 SYSCONF_LIBS =
38 38
39# Link flags for shared objects 39# Link flags for shared objects
40 SYSCONF_LFLAGS_SHOBJ= -shared 40 SYSCONF_LFLAGS_SHOBJ= -shared
41 41
42# Flags for threading 42# Flags for threading
43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT 43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT 44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
45 SYSCONF_LFLAGS_THREAD= 45 SYSCONF_LFLAGS_THREAD=
46 SYSCONF_LIBS_THREAD= -lpthread 46 SYSCONF_LIBS_THREAD= -lpthread
47 47
48# Meta-object compiler 48# Meta-object compiler
49 SYSCONF_MOC = $(QTDIR)/bin/moc 49 SYSCONF_MOC = $(QTDIR)/bin/moc
50 50
51# UI compiler 51# UI compiler
52 SYSCONF_UIC = $(QTDIR)/bin/uic 52 SYSCONF_UIC = $(QTDIR)/bin/uic
53 53
54# Linking shared libraries 54# Linking shared libraries
55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
56# - Place target in $(DESTDIR) - which has a trailing / 56# - Place target in $(DESTDIR) - which has a trailing /
57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) 57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
58# 58#
59 SYSCONF_LINK_SHLIB= arm-linux-gcc 59 SYSCONF_LINK_SHLIB= arm-linux-gcc
60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) 60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ 61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ 62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
63 $(OBJECTS) $(OBJMOC) $(LIBS) && \ 63 $(OBJECTS) $(OBJMOC) $(LIBS) && \
64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ 64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
65 cd $(DESTDIR) && \ 65 cd $(DESTDIR) && \
66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ 66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ 67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ 68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) 69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
70 70
71# Linking static libraries 71# Linking static libraries
72# - Build the $(TARGET) library, eg. lib$(TARGET).a 72# - Build the $(TARGET) library, eg. lib$(TARGET).a
73# - Place target in $(DESTDIR) - which has a trailing / 73# - Place target in $(DESTDIR) - which has a trailing /
74# 74#
75 SYSCONF_AR = arm-linux-ar cqs 75 SYSCONF_AR = arm-linux-ar cqs
76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a 76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ 77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) 78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
79# Compiling application source 79# Compiling application source
80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W 80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_SHARP -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W
81 SYSCONF_CFLAGS = -pipe -O2 -Wall -W 81 SYSCONF_CFLAGS = -pipe -O2 -Wall -W
82 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_STATIC) 82 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_STATIC)
83 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_STATIC) 83 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_STATIC)
84# Compiling library source 84# Compiling library source
85 SYSCONF_CXXFLAGS_LIB= 85 SYSCONF_CXXFLAGS_LIB=
86 SYSCONF_CFLAGS_LIB= 86 SYSCONF_CFLAGS_LIB=
87# Compiling shared-object source 87# Compiling shared-object source
88 SYSCONF_CXXFLAGS_SHOBJ= -fPIC 88 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
89 SYSCONF_CFLAGS_SHOBJ= -fPIC 89 SYSCONF_CFLAGS_SHOBJ= -fPIC
90# Linking Qt 90# Linking Qt
91 SYSCONF_LIBS_QTLIB= $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) 91 SYSCONF_LIBS_QTLIB= $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
92# Linking Qt applications 92# Linking Qt applications
93 SYSCONF_LIBS_QTAPP= $(SYSCONF_LFLAGS_X11) $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) $(SYSCONF_LIBS_X11) 93 SYSCONF_LIBS_QTAPP= $(SYSCONF_LFLAGS_X11) $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) $(SYSCONF_LIBS_X11)
diff --git a/configs/linux-sharp-g++-static-debug b/configs/linux-sharp-g++-static-debug
index d7715ed..9c1afd3 100644
--- a/configs/linux-sharp-g++-static-debug
+++ b/configs/linux-sharp-g++-static-debug
@@ -1,93 +1,93 @@
1# Compiling 1# Compiling
2 INTERFACE_DECL_PATH = . 2 INTERFACE_DECL_PATH = .
3 SYSCONF_CXX = arm-linux-g++ 3 SYSCONF_CXX = arm-linux-g++
4 SYSCONF_CC = arm-linux-gcc 4 SYSCONF_CC = arm-linux-gcc
5 DASHCROSS = -arm 5 DASHCROSS = -arm
6 6
7# Compiling with support libraries 7# Compiling with support libraries
8 SYSCONF_CXXFLAGS_X11= 8 SYSCONF_CXXFLAGS_X11=
9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include 9 SYSCONF_CXXFLAGS_QT= -I$(QTDIR)/include
10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include 10 SYSCONF_CXXFLAGS_OPENGL= -I/usr/X11R6/include
11 11
12# Compiling YACC output 12# Compiling YACC output
13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses 13SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses
14 14
15# Linking with support libraries 15# Linking with support libraries
16 SYSCONF_RPATH_X11= 16 SYSCONF_RPATH_X11=
17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib 17 SYSCONF_RPATH_QT= -Wl,-rpath,$(QTDIR)/lib
18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib 18 SYSCONF_RPATH_OPENGL= -Wl,-rpath,/usr/X11R6/lib
19 19
20# Linking with support libraries 20# Linking with support libraries
21# X11 21# X11
22 SYSCONF_LFLAGS_X11= 22 SYSCONF_LFLAGS_X11=
23 SYSCONF_LIBS_X11= 23 SYSCONF_LIBS_X11=
24# Qt, Qt+OpenGL 24# Qt, Qt+OpenGL
25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib 25 SYSCONF_LFLAGS_QT= -L$(QTDIR)/lib
26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) 26 SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX)
27 SYSCONF_LIBS_QT_OPENGL= 27 SYSCONF_LIBS_QT_OPENGL=
28# OpenGL 28# OpenGL
29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib 29 SYSCONF_LFLAGS_OPENGL= -L/usr/X11R6/lib
30 SYSCONF_LIBS_OPENGL= 30 SYSCONF_LIBS_OPENGL=
31# Yacc 31# Yacc
32 SYSCONF_LIBS_YACC= 32 SYSCONF_LIBS_YACC=
33 33
34# Linking applications 34# Linking applications
35 SYSCONF_LINK = arm-linux-gcc 35 SYSCONF_LINK = arm-linux-gcc
36 SYSCONF_LFLAGS = 36 SYSCONF_LFLAGS =
37 SYSCONF_LIBS = 37 SYSCONF_LIBS =
38 38
39# Link flags for shared objects 39# Link flags for shared objects
40 SYSCONF_LFLAGS_SHOBJ= -shared 40 SYSCONF_LFLAGS_SHOBJ= -shared
41 41
42# Flags for threading 42# Flags for threading
43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT 43 SYSCONF_CFLAGS_THREAD= -D_REENTRANT
44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT 44 SYSCONF_CXXFLAGS_THREAD= -D_REENTRANT
45 SYSCONF_LFLAGS_THREAD= 45 SYSCONF_LFLAGS_THREAD=
46 SYSCONF_LIBS_THREAD= -lpthread 46 SYSCONF_LIBS_THREAD= -lpthread
47 47
48# Meta-object compiler 48# Meta-object compiler
49 SYSCONF_MOC = $(QTDIR)/bin/moc 49 SYSCONF_MOC = $(QTDIR)/bin/moc
50 50
51# UI compiler 51# UI compiler
52 SYSCONF_UIC = $(QTDIR)/bin/uic 52 SYSCONF_UIC = $(QTDIR)/bin/uic
53 53
54# Linking shared libraries 54# Linking shared libraries
55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 55# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2
56# - Place target in $(DESTDIR) - which has a trailing / 56# - Place target in $(DESTDIR) - which has a trailing /
57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) 57# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH)
58# 58#
59 SYSCONF_LINK_SHLIB= arm-linux-gcc 59 SYSCONF_LINK_SHLIB= arm-linux-gcc
60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) 60 SYSCONF_LINK_TARGET_SHARED= lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ 61 SYSCONF_LINK_LIB_SHARED= $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \
62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ 62 $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \
63 $(OBJECTS) $(OBJMOC) $(LIBS) && \ 63 $(OBJECTS) $(OBJMOC) $(LIBS) && \
64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ 64 mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \
65 cd $(DESTDIR) && \ 65 cd $(DESTDIR) && \
66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ 66 rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \
67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ 67 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \
68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ 68 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \
69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) 69 ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN)
70 70
71# Linking static libraries 71# Linking static libraries
72# - Build the $(TARGET) library, eg. lib$(TARGET).a 72# - Build the $(TARGET) library, eg. lib$(TARGET).a
73# - Place target in $(DESTDIR) - which has a trailing / 73# - Place target in $(DESTDIR) - which has a trailing /
74# 74#
75 SYSCONF_AR = arm-linux-ar cqs 75 SYSCONF_AR = arm-linux-ar cqs
76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a 76SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a
77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ 77 SYSCONF_LINK_LIB_STATIC= rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \
78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) 78 $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC)
79# Compiling application source 79# Compiling application source
80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -fno-exceptions -fno-rtti -g -Wall -W 80 SYSCONF_CXXFLAGS= -pipe -DQT_QWS_EBX -DQT_QWS_SHARP -DQWS -fno-exceptions -fno-rtti -g -Wall -W
81 SYSCONF_CFLAGS = -pipe -g -Wall -W 81 SYSCONF_CFLAGS = -pipe -g -Wall -W
82 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_STATIC) 82 SYSCONF_LINK_LIB= $(SYSCONF_LINK_LIB_STATIC)
83 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_STATIC) 83 SYSCONF_LINK_TARGET= $(SYSCONF_LINK_TARGET_STATIC)
84# Compiling library source 84# Compiling library source
85 SYSCONF_CXXFLAGS_LIB= 85 SYSCONF_CXXFLAGS_LIB=
86 SYSCONF_CFLAGS_LIB= 86 SYSCONF_CFLAGS_LIB=
87# Compiling shared-object source 87# Compiling shared-object source
88 SYSCONF_CXXFLAGS_SHOBJ= -fPIC 88 SYSCONF_CXXFLAGS_SHOBJ= -fPIC
89 SYSCONF_CFLAGS_SHOBJ= -fPIC 89 SYSCONF_CFLAGS_SHOBJ= -fPIC
90# Linking Qt 90# Linking Qt
91 SYSCONF_LIBS_QTLIB= $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) 91 SYSCONF_LIBS_QTLIB= $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT)
92# Linking Qt applications 92# Linking Qt applications
93 SYSCONF_LIBS_QTAPP= $(SYSCONF_LFLAGS_X11) $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) $(SYSCONF_LIBS_X11) 93 SYSCONF_LIBS_QTAPP= $(SYSCONF_LFLAGS_X11) $(SYSCONF_CXXFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) $(SYSCONF_LIBS_X11)
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index d6ee6e8..cacc3c4 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -1,1347 +1,1347 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
4/* */ 4/* */
5/* ------------------------------------------------------------------------ */ 5/* ------------------------------------------------------------------------ */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------ */ 11/* ------------------------------------------------------------------------ */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/*! \class TEWidget 18/*! \class TEWidget
19 19
20 \brief Visible screen contents 20 \brief Visible screen contents
21 21
22 This class is responsible to map the `image' of a terminal emulation to the 22 This class is responsible to map the `image' of a terminal emulation to the
23 display. All the dependency of the emulation to a specific GUI or toolkit is 23 display. All the dependency of the emulation to a specific GUI or toolkit is
24 localized here. Further, this widget has no knowledge about being part of an 24 localized here. Further, this widget has no knowledge about being part of an
25 emulation, it simply work within the terminal emulation framework by exposing 25 emulation, it simply work within the terminal emulation framework by exposing
26 size and key events and by being ordered to show a new image. 26 size and key events and by being ordered to show a new image.
27 27
28 <ul> 28 <ul>
29 <li> The internal image has the size of the widget (evtl. rounded up) 29 <li> The internal image has the size of the widget (evtl. rounded up)
30 <li> The external image used in setImage can have any size. 30 <li> The external image used in setImage can have any size.
31 <li> (internally) the external image is simply copied to the internal 31 <li> (internally) the external image is simply copied to the internal
32 when a setImage happens. During a resizeEvent no painting is done 32 when a setImage happens. During a resizeEvent no painting is done
33 a paintEvent is expected to follow anyway. 33 a paintEvent is expected to follow anyway.
34 </ul> 34 </ul>
35 35
36 \sa TEScreen \sa Emulation 36 \sa TEScreen \sa Emulation
37*/ 37*/
38 38
39/* FIXME: 39/* FIXME:
40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
41 - 'font_a' not used in mouse events 41 - 'font_a' not used in mouse events
42 - add destructor 42 - add destructor
43*/ 43*/
44 44
45/* TODO 45/* TODO
46 - evtl. be sensitive to `paletteChange' while using default colors. 46 - evtl. be sensitive to `paletteChange' while using default colors.
47 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 47 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
48*/ 48*/
49 49
50// #include "config.h" 50// #include "config.h"
51#include "TEWidget.h" 51#include "TEWidget.h"
52#include "session.h" 52#include "session.h"
53#include <qpe/config.h> 53#include <qpe/config.h>
54 54
55#include <qpe/resource.h> 55#include <qpe/resource.h>
56#include <qpe/sound.h> 56#include <qpe/sound.h>
57 57
58#ifdef QWS 58#ifdef QWS
59#include <qpe/qcopenvelope_qws.h> 59#include <qpe/qcopenvelope_qws.h>
60#endif 60#endif
61 61
62#include <qcursor.h> 62#include <qcursor.h>
63#include <qregexp.h> 63#include <qregexp.h>
64#include <qpainter.h> 64#include <qpainter.h>
65#include <qclipboard.h> 65#include <qclipboard.h>
66#include <qstyle.h> 66#include <qstyle.h>
67#include <qfile.h> 67#include <qfile.h>
68#include <qdragobject.h> 68#include <qdragobject.h>
69 69
70#include <stdio.h> 70#include <stdio.h>
71#include <stdlib.h> 71#include <stdlib.h>
72#include <unistd.h> 72#include <unistd.h>
73#include <ctype.h> 73#include <ctype.h>
74#include <sys/stat.h> 74#include <sys/stat.h>
75#include <sys/types.h> 75#include <sys/types.h>
76#include <signal.h> 76#include <signal.h>
77 77
78#include <assert.h> 78#include <assert.h>
79 79
80// #include "TEWidget.moc" 80// #include "TEWidget.moc"
81//#include <kapp.h> 81//#include <kapp.h>
82//#include <kcursor.h> 82//#include <kcursor.h>
83//#include <kurl.h> 83//#include <kurl.h>
84//#include <kdebug.h> 84//#include <kdebug.h>
85//#include <klocale.h> 85//#include <klocale.h>
86 86
87#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 87#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
88#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 88#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
89 89
90#define loc(X,Y) ((Y)*columns+(X)) 90#define loc(X,Y) ((Y)*columns+(X))
91 91
92//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 92//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
93#define rimX 0 // left/right rim width 93#define rimX 0 // left/right rim width
94#define rimY 0 // top/bottom rim high 94#define rimY 0 // top/bottom rim high
95 95
96#define SCRWIDTH 16 // width of the scrollbar 96#define SCRWIDTH 16 // width of the scrollbar
97 97
98#define yMouseScroll 1 98#define yMouseScroll 1
99// scroll increment used when dragging selection at top/bottom of window. 99// scroll increment used when dragging selection at top/bottom of window.
100 100
101/* ------------------------------------------------------------------------- */ 101/* ------------------------------------------------------------------------- */
102/* */ 102/* */
103/* Colors */ 103/* Colors */
104/* */ 104/* */
105/* ------------------------------------------------------------------------- */ 105/* ------------------------------------------------------------------------- */
106 106
107//FIXME: the default color table is in session.C now. 107//FIXME: the default color table is in session.C now.
108// We need a way to get rid of this one, here. 108// We need a way to get rid of this one, here.
109static const ColorEntry base_color_table[TABLE_COLORS] = 109static const ColorEntry base_color_table[TABLE_COLORS] =
110// The following are almost IBM standard color codes, with some slight 110// The following are almost IBM standard color codes, with some slight
111// gamma correction for the dim colors to compensate for bright X screens. 111// gamma correction for the dim colors to compensate for bright X screens.
112// It contains the 8 ansiterm/xterm colors in 2 intensities. 112// It contains the 8 ansiterm/xterm colors in 2 intensities.
113{ 113{
114 // Fixme: could add faint colors here, also. 114 // Fixme: could add faint colors here, also.
115 // normal 115 // normal
116 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 116 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
118 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 118 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
119 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 119 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
120 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 120 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
121 // intensiv 121 // intensiv
122 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 122 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
123 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 123 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
124 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 124 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
125 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 125 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
126 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 126 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
127}; 127};
128 128
129/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 129/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
130 130
131 Code 0 1 2 3 4 5 6 7 131 Code 0 1 2 3 4 5 6 7
132 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 132 ----------- ------- ------- ------- ------- ------- ------- ------- -------
133 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 133 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
134 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 134 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
135*/ 135*/
136 136
137QColor TEWidget::getDefaultBackColor() 137QColor TEWidget::getDefaultBackColor()
138{ 138{
139 return color_table[DEFAULT_BACK_COLOR].color; 139 return color_table[DEFAULT_BACK_COLOR].color;
140} 140}
141 141
142const ColorEntry* TEWidget::getColorTable() const 142const ColorEntry* TEWidget::getColorTable() const
143{ 143{
144 return color_table; 144 return color_table;
145} 145}
146 146
147const ColorEntry* TEWidget::getdefaultColorTable() const 147const ColorEntry* TEWidget::getdefaultColorTable() const
148{ 148{
149 return base_color_table; 149 return base_color_table;
150} 150}
151 151
152 152
153const QPixmap *TEWidget::backgroundPixmap() 153const QPixmap *TEWidget::backgroundPixmap()
154{ 154{
155 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 155 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
156 const QPixmap *pm = bg; 156 const QPixmap *pm = bg;
157 return pm; 157 return pm;
158} 158}
159 159
160void TEWidget::setColorTable(const ColorEntry table[]) 160void TEWidget::setColorTable(const ColorEntry table[])
161{ 161{
162 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 162 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
163 163
164 const QPixmap* pm = backgroundPixmap(); 164 const QPixmap* pm = backgroundPixmap();
165 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 165 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
166 update(); 166 update();
167} 167}
168 168
169//FIXME: add backgroundPixmapChanged. 169//FIXME: add backgroundPixmapChanged.
170 170
171/* ------------------------------------------------------------------------- */ 171/* ------------------------------------------------------------------------- */
172/* */ 172/* */
173/* Font */ 173/* Font */
174/* */ 174/* */
175/* ------------------------------------------------------------------------- */ 175/* ------------------------------------------------------------------------- */
176 176
177/* 177/*
178 The VT100 has 32 special graphical characters. The usual vt100 extended 178 The VT100 has 32 special graphical characters. The usual vt100 extended
179 xterm fonts have these at 0x00..0x1f. 179 xterm fonts have these at 0x00..0x1f.
180 180
181 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 181 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
182 come in here as proper unicode characters. 182 come in here as proper unicode characters.
183 183
184 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 184 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
185 from unicode to 0x00..0x1f. The remaining translation is then left to the 185 from unicode to 0x00..0x1f. The remaining translation is then left to the
186 QCodec. 186 QCodec.
187*/ 187*/
188 188
189// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 189// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
190 190
191unsigned short vt100_graphics[32] = 191unsigned short vt100_graphics[32] =
192{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 192{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
193 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 193 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
194 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 194 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
195 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 195 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
196 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 196 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
197}; 197};
198 198
199static QChar vt100extended(QChar c) 199static QChar vt100extended(QChar c)
200{ 200{
201 switch (c.unicode()) 201 switch (c.unicode())
202 { 202 {
203 case 0x25c6 : return 1; 203 case 0x25c6 : return 1;
204 case 0x2592 : return 2; 204 case 0x2592 : return 2;
205 case 0x2409 : return 3; 205 case 0x2409 : return 3;
206 case 0x240c : return 4; 206 case 0x240c : return 4;
207 case 0x240d : return 5; 207 case 0x240d : return 5;
208 case 0x240a : return 6; 208 case 0x240a : return 6;
209 case 0x00b0 : return 7; 209 case 0x00b0 : return 7;
210 case 0x00b1 : return 8; 210 case 0x00b1 : return 8;
211 case 0x2424 : return 9; 211 case 0x2424 : return 9;
212 case 0x240b : return 10; 212 case 0x240b : return 10;
213 case 0x2518 : return 11; 213 case 0x2518 : return 11;
214 case 0x2510 : return 12; 214 case 0x2510 : return 12;
215 case 0x250c : return 13; 215 case 0x250c : return 13;
216 case 0x2514 : return 14; 216 case 0x2514 : return 14;
217 case 0x253c : return 15; 217 case 0x253c : return 15;
218 case 0xf800 : return 16; 218 case 0xf800 : return 16;
219 case 0xf801 : return 17; 219 case 0xf801 : return 17;
220 case 0x2500 : return 18; 220 case 0x2500 : return 18;
221 case 0xf803 : return 19; 221 case 0xf803 : return 19;
222 case 0xf804 : return 20; 222 case 0xf804 : return 20;
223 case 0x251c : return 21; 223 case 0x251c : return 21;
224 case 0x2524 : return 22; 224 case 0x2524 : return 22;
225 case 0x2534 : return 23; 225 case 0x2534 : return 23;
226 case 0x252c : return 24; 226 case 0x252c : return 24;
227 case 0x2502 : return 25; 227 case 0x2502 : return 25;
228 case 0x2264 : return 26; 228 case 0x2264 : return 26;
229 case 0x2265 : return 27; 229 case 0x2265 : return 27;
230 case 0x03c0 : return 28; 230 case 0x03c0 : return 28;
231 case 0x2260 : return 29; 231 case 0x2260 : return 29;
232 case 0x00a3 : return 30; 232 case 0x00a3 : return 30;
233 case 0x00b7 : return 31; 233 case 0x00b7 : return 31;
234 } 234 }
235 return c; 235 return c;
236} 236}
237 237
238static QChar identicalMap(QChar c) 238static QChar identicalMap(QChar c)
239{ 239{
240 return c; 240 return c;
241} 241}
242 242
243void TEWidget::fontChange(const QFont &) 243void TEWidget::fontChange(const QFont &)
244{ 244{
245 QFontMetrics fm(font()); 245 QFontMetrics fm(font());
246 font_h = fm.height(); 246 font_h = fm.height();
247 font_w = fm.maxWidth(); 247 font_w = fm.maxWidth();
248 font_a = fm.ascent(); 248 font_a = fm.ascent();
249//printf("font_h: %d\n",font_h); 249//printf("font_h: %d\n",font_h);
250//printf("font_w: %d\n",font_w); 250//printf("font_w: %d\n",font_w);
251//printf("font_a: %d\n",font_a); 251//printf("font_a: %d\n",font_a);
252//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 252//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
253//printf("rawname: %s\n",font().rawName().ascii()); 253//printf("rawname: %s\n",font().rawName().ascii());
254 fontMap = 254 fontMap =
255#if QT_VERSION < 300 255#if QT_VERSION < 300
256 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 256 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
257 ? vt100extended 257 ? vt100extended
258 : 258 :
259#endif 259#endif
260 identicalMap; 260 identicalMap;
261 propagateSize(); 261 propagateSize();
262 update(); 262 update();
263} 263}
264 264
265void TEWidget::setVTFont(const QFont& f) 265void TEWidget::setVTFont(const QFont& f)
266{ 266{
267 QFrame::setFont(f); 267 QFrame::setFont(f);
268} 268}
269 269
270QFont TEWidget::getVTFont() { 270QFont TEWidget::getVTFont() {
271 return font(); 271 return font();
272} 272}
273 273
274void TEWidget::setFont(const QFont &) 274void TEWidget::setFont(const QFont &)
275{ 275{
276 // ignore font change request if not coming from konsole itself 276 // ignore font change request if not coming from konsole itself
277} 277}
278 278
279/* ------------------------------------------------------------------------- */ 279/* ------------------------------------------------------------------------- */
280/* */ 280/* */
281/* Constructor / Destructor */ 281/* Constructor / Destructor */
282/* */ 282/* */
283/* ------------------------------------------------------------------------- */ 283/* ------------------------------------------------------------------------- */
284 284
285TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 285TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
286{ 286{
287#ifndef QT_NO_CLIPBOARD 287#ifndef QT_NO_CLIPBOARD
288 cb = QApplication::clipboard(); 288 cb = QApplication::clipboard();
289 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 289 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
290 this, SLOT(onClearSelection()) ); 290 this, SLOT(onClearSelection()) );
291#endif 291#endif
292 292
293 scrollbar = new QScrollBar(this); 293 scrollbar = new QScrollBar(this);
294 scrollbar->setCursor( arrowCursor ); 294 scrollbar->setCursor( arrowCursor );
295 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 295 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
296 296
297 hScrollbar = new QScrollBar(this); 297 hScrollbar = new QScrollBar(this);
298 hScrollbar->setCursor( arrowCursor ); 298 hScrollbar->setCursor( arrowCursor );
299 hScrollbar->setOrientation(QScrollBar::Horizontal); 299 hScrollbar->setOrientation(QScrollBar::Horizontal);
300 hScrollbar->setMaximumHeight(16); 300 hScrollbar->setMaximumHeight(16);
301 301
302 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); 302 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
303 303
304 Config cfg("Konsole"); 304 Config cfg("Konsole");
305 cfg.setGroup("ScrollBar"); 305 cfg.setGroup("ScrollBar");
306 switch( cfg.readNumEntry("Position",2)){ 306 switch( cfg.readNumEntry("Position",2)){
307 case 0: 307 case 0:
308 scrollLoc = SCRNONE; 308 scrollLoc = SCRNONE;
309 break; 309 break;
310 case 1: 310 case 1:
311 scrollLoc = SCRLEFT; 311 scrollLoc = SCRLEFT;
312 break; 312 break;
313 case 2: 313 case 2:
314 scrollLoc = SCRRIGHT; 314 scrollLoc = SCRRIGHT;
315 break; 315 break;
316 }; 316 };
317 317
318 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 318 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
319 319
320 blinkT = new QTimer(this); 320 blinkT = new QTimer(this);
321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
322 // blinking = FALSE; 322 // blinking = FALSE;
323 blinking = TRUE; 323 blinking = TRUE;
324 324
325 resizing = FALSE; 325 resizing = FALSE;
326 actSel = 0; 326 actSel = 0;
327 image = 0; 327 image = 0;
328 lines = 1; 328 lines = 1;
329 columns = 1; 329 columns = 1;
330 font_w = 1; 330 font_w = 1;
331 font_h = 1; 331 font_h = 1;
332 font_a = 1; 332 font_a = 1;
333 word_selection_mode = FALSE; 333 word_selection_mode = FALSE;
334 hposition = 0; 334 hposition = 0;
335vcolumns = 0; 335vcolumns = 0;
336 336
337 setMouseMarks(TRUE); 337 setMouseMarks(TRUE);
338 setVTFont( QFont("fixed") ); 338 setVTFont( QFont("fixed") );
339 setColorTable(base_color_table); // init color table 339 setColorTable(base_color_table); // init color table
340 340
341 qApp->installEventFilter( this ); //FIXME: see below 341 qApp->installEventFilter( this ); //FIXME: see below
342// KCursor::setAutoHideCursor( this, true ); 342// KCursor::setAutoHideCursor( this, true );
343 343
344 // Init DnD //////////////////////////////////////////////////////////////// 344 // Init DnD ////////////////////////////////////////////////////////////////
345 currentSession = NULL; 345 currentSession = NULL;
346// setAcceptDrops(true); // attempt 346// setAcceptDrops(true); // attempt
347// m_drop = new QPopupMenu(this); 347// m_drop = new QPopupMenu(this);
348// m_drop->insertItem( QString("Paste"), 0); 348// m_drop->insertItem( QString("Paste"), 0);
349// m_drop->insertItem( QString("cd"), 1); 349// m_drop->insertItem( QString("cd"), 1);
350// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 350// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
351 351
352 // we need focus so that the auto-hide cursor feature works 352 // we need focus so that the auto-hide cursor feature works
353 setFocus(); 353 setFocus();
354 setFocusPolicy( WheelFocus ); 354 setFocusPolicy( WheelFocus );
355} 355}
356 356
357//FIXME: make proper destructor 357//FIXME: make proper destructor
358// Here's a start (David) 358// Here's a start (David)
359TEWidget::~TEWidget() 359TEWidget::~TEWidget()
360{ 360{
361 qApp->removeEventFilter( this ); 361 qApp->removeEventFilter( this );
362 if (image) free(image); 362 if (image) free(image);
363} 363}
364 364
365/* ------------------------------------------------------------------------- */ 365/* ------------------------------------------------------------------------- */
366/* */ 366/* */
367/* Display Operations */ 367/* Display Operations */
368/* */ 368/* */
369/* ------------------------------------------------------------------------- */ 369/* ------------------------------------------------------------------------- */
370 370
371/*! 371/*!
372 attributed string draw primitive 372 attributed string draw primitive
373*/ 373*/
374 374
375void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 375void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
376 QString& str, ca attr, BOOL pm, BOOL clear) 376 QString& str, ca attr, BOOL pm, BOOL clear)
377{ 377{
378 if (pm && color_table[attr.b].transparent) 378 if (pm && color_table[attr.b].transparent)
379 { 379 {
380 paint.setBackgroundMode( TransparentMode ); 380 paint.setBackgroundMode( TransparentMode );
381 if (clear) erase(rect); 381 if (clear) erase(rect);
382 } 382 }
383 else 383 else
384 { 384 {
385 if (blinking) 385 if (blinking)
386 paint.fillRect(rect, color_table[attr.b].color); 386 paint.fillRect(rect, color_table[attr.b].color);
387 else 387 else
388 { 388 {
389 paint.setBackgroundMode( OpaqueMode ); 389 paint.setBackgroundMode( OpaqueMode );
390 paint.setBackgroundColor( color_table[attr.b].color ); 390 paint.setBackgroundColor( color_table[attr.b].color );
391 } 391 }
392 } 392 }
393 393
394 if (color_table[attr.f].bold) 394 if (color_table[attr.f].bold)
395 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 395 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
396 else 396 else
397 paint.setPen(color_table[attr.f].color); 397 paint.setPen(color_table[attr.f].color);
398 398
399 paint.drawText(rect.x(),rect.y()+font_a, str); 399 paint.drawText(rect.x(),rect.y()+font_a, str);
400 400
401 if (attr.r & RE_UNDERLINE) 401 if (attr.r & RE_UNDERLINE)
402 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 402 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
403} 403}
404 404
405/*! 405/*!
406 The image can only be set completely. 406 The image can only be set completely.
407 407
408 The size of the new image may or may not match the size of the widget. 408 The size of the new image may or may not match the size of the widget.
409*/ 409*/
410 410
411void TEWidget::setImage(const ca* const newimg, int lines, int columns) 411void TEWidget::setImage(const ca* const newimg, int lines, int columns)
412{ int y,x,len; 412{ int y,x,len;
413 const QPixmap* pm = backgroundPixmap(); 413 const QPixmap* pm = backgroundPixmap();
414 QPainter paint; 414 QPainter paint;
415 setUpdatesEnabled(FALSE); 415 setUpdatesEnabled(FALSE);
416 paint.begin( this ); 416 paint.begin( this );
417HCNT("setImage"); 417HCNT("setImage");
418 418
419 QPoint tL = contentsRect().topLeft(); 419 QPoint tL = contentsRect().topLeft();
420 int tLx = tL.x(); 420 int tLx = tL.x();
421 int tLy = tL.y(); 421 int tLy = tL.y();
422 hasBlinker = FALSE; 422 hasBlinker = FALSE;
423 423
424 int cf = -1; // undefined 424 int cf = -1; // undefined
425 int cb = -1; // undefined 425 int cb = -1; // undefined
426 int cr = -1; // undefined 426 int cr = -1; // undefined
427 427
428 int lins = QMIN(this->lines, QMAX(0,lines )); 428 int lins = QMIN(this->lines, QMAX(0,lines ));
429 int cols = QMIN(this->columns,QMAX(0,columns)); 429 int cols = QMIN(this->columns,QMAX(0,columns));
430 QChar *disstrU = new QChar[cols]; 430 QChar *disstrU = new QChar[cols];
431 for (y = 0; y < lins; y++) { 431 for (y = 0; y < lins; y++) {
432 const ca* lcl = &image[y*this->columns]; 432 const ca* lcl = &image[y*this->columns];
433 const ca* const ext = &newimg[y*columns]; 433 const ca* const ext = &newimg[y*columns];
434 if (!resizing) // not while resizing, we're expecting a paintEvent 434 if (!resizing) // not while resizing, we're expecting a paintEvent
435 for (x = 0; x < cols; x++) 435 for (x = 0; x < cols; x++)
436 { 436 {
437 hasBlinker |= (ext[x].r & RE_BLINK); 437 hasBlinker |= (ext[x].r & RE_BLINK);
438 if (ext[x] != lcl[x]) 438 if (ext[x] != lcl[x])
439 { 439 {
440 cr = ext[x].r; 440 cr = ext[x].r;
441 cb = ext[x].b; 441 cb = ext[x].b;
442 if (ext[x].f != cf) cf = ext[x].f; 442 if (ext[x].f != cf) cf = ext[x].f;
443 int lln = cols - x; 443 int lln = cols - x;
444 disstrU[0] = fontMap(ext[x+0].c); 444 disstrU[0] = fontMap(ext[x+0].c);
445 for (len = 1; len < lln; len++) 445 for (len = 1; len < lln; len++)
446 { 446 {
447 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 447 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
448 ext[x+len] == lcl[x+len] ) 448 ext[x+len] == lcl[x+len] )
449 break; 449 break;
450 disstrU[len] = fontMap(ext[x+len].c); 450 disstrU[len] = fontMap(ext[x+len].c);
451 } 451 }
452 QString unistr(disstrU,len); 452 QString unistr(disstrU,len);
453 drawAttrStr(paint, 453 drawAttrStr(paint,
454 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 454 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
455 unistr, ext[x], pm != NULL, true); 455 unistr, ext[x], pm != NULL, true);
456 x += len - 1; 456 x += len - 1;
457 } 457 }
458 } 458 }
459 // finally, make `image' become `newimg'. 459 // finally, make `image' become `newimg'.
460 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 460 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
461 } 461 }
462 drawFrame( &paint ); 462 drawFrame( &paint );
463 paint.end(); 463 paint.end();
464 setUpdatesEnabled(TRUE); 464 setUpdatesEnabled(TRUE);
465 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 465 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
466 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 466 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
467 delete [] disstrU; 467 delete [] disstrU;
468} 468}
469 469
470// paint Event //////////////////////////////////////////////////// 470// paint Event ////////////////////////////////////////////////////
471 471
472/*! 472/*!
473 The difference of this routine vs. the `setImage' is, 473 The difference of this routine vs. the `setImage' is,
474 that the drawing does not include a difference analysis 474 that the drawing does not include a difference analysis
475 between the old and the new image. Instead, the internal 475 between the old and the new image. Instead, the internal
476 image is used and the painting bound by the PaintEvent box. 476 image is used and the painting bound by the PaintEvent box.
477*/ 477*/
478 478
479void TEWidget::paintEvent( QPaintEvent* pe ) 479void TEWidget::paintEvent( QPaintEvent* pe )
480{ 480{
481 481
482//{ static int cnt = 0; printf("paint %d\n",cnt++); } 482//{ static int cnt = 0; printf("paint %d\n",cnt++); }
483 const QPixmap* pm = backgroundPixmap(); 483 const QPixmap* pm = backgroundPixmap();
484 QPainter paint; 484 QPainter paint;
485 setUpdatesEnabled(FALSE); 485 setUpdatesEnabled(FALSE);
486 paint.begin( this ); 486 paint.begin( this );
487 paint.setBackgroundMode( TransparentMode ); 487 paint.setBackgroundMode( TransparentMode );
488HCNT("paintEvent"); 488HCNT("paintEvent");
489 489
490 // Note that the actual widget size can be slightly larger 490 // Note that the actual widget size can be slightly larger
491 // that the image (the size is truncated towards the smaller 491 // that the image (the size is truncated towards the smaller
492 // number of characters in `resizeEvent'. The paint rectangle 492 // number of characters in `resizeEvent'. The paint rectangle
493 // can thus be larger than the image, but less then the size 493 // can thus be larger than the image, but less then the size
494 // of one character. 494 // of one character.
495 495
496 QRect rect = pe->rect().intersect(contentsRect()); 496 QRect rect = pe->rect().intersect(contentsRect());
497 497
498 QPoint tL = contentsRect().topLeft(); 498 QPoint tL = contentsRect().topLeft();
499 int tLx = tL.x(); 499 int tLx = tL.x();
500 int tLy = tL.y(); 500 int tLy = tL.y();
501 501
502 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 502 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
503 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 503 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
504 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 504 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
505 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 505 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
506 506
507 /* 507 /*
508 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 508 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
509 rect.left(), rect.right(), rect.top(), rect.bottom()); 509 rect.left(), rect.right(), rect.top(), rect.bottom());
510 */ 510 */
511 511
512 // if (pm != NULL && color_table[image->b].transparent) 512 // if (pm != NULL && color_table[image->b].transparent)
513 // erase(rect); 513 // erase(rect);
514 // BL: I have no idea why we need this, and it breaks the refresh. 514 // BL: I have no idea why we need this, and it breaks the refresh.
515 515
516 QChar *disstrU = new QChar[columns]; 516 QChar *disstrU = new QChar[columns];
517 for (int y = luy; y <= rly; y++) 517 for (int y = luy; y <= rly; y++)
518 for (int x = lux; x <= rlx; x++) 518 for (int x = lux; x <= rlx; x++)
519 { 519 {
520 int len = 1; 520 int len = 1;
521 disstrU[0] = fontMap(image[loc(x,y)].c); 521 disstrU[0] = fontMap(image[loc(x,y)].c);
522 int cf = image[loc(x,y)].f; 522 int cf = image[loc(x,y)].f;
523 int cb = image[loc(x,y)].b; 523 int cb = image[loc(x,y)].b;
524 int cr = image[loc(x,y)].r; 524 int cr = image[loc(x,y)].r;
525 while (x+len <= rlx && 525 while (x+len <= rlx &&
526 image[loc(x+len,y)].f == cf && 526 image[loc(x+len,y)].f == cf &&
527 image[loc(x+len,y)].b == cb && 527 image[loc(x+len,y)].b == cb &&
528 image[loc(x+len,y)].r == cr ) 528 image[loc(x+len,y)].r == cr )
529 { 529 {
530 disstrU[len] = fontMap(image[loc(x+len,y)].c); 530 disstrU[len] = fontMap(image[loc(x+len,y)].c);
531 len += 1; 531 len += 1;
532 } 532 }
533 QString unistr(disstrU,len); 533 QString unistr(disstrU,len);
534 drawAttrStr(paint, 534 drawAttrStr(paint,
535 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 535 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
536 unistr, image[loc(x,y)], pm != NULL, false); 536 unistr, image[loc(x,y)], pm != NULL, false);
537 x += len - 1; 537 x += len - 1;
538 } 538 }
539 delete [] disstrU; 539 delete [] disstrU;
540 drawFrame( &paint ); 540 drawFrame( &paint );
541 paint.end(); 541 paint.end();
542 setUpdatesEnabled(TRUE); 542 setUpdatesEnabled(TRUE);
543} 543}
544 544
545void TEWidget::blinkEvent() 545void TEWidget::blinkEvent()
546{ 546{
547 blinking = !blinking; 547 blinking = !blinking;
548 repaint(FALSE); 548 repaint(FALSE);
549} 549}
550 550
551/* ------------------------------------------------------------------------- */ 551/* ------------------------------------------------------------------------- */
552/* */ 552/* */
553/* Resizing */ 553/* Resizing */
554/* */ 554/* */
555/* ------------------------------------------------------------------------- */ 555/* ------------------------------------------------------------------------- */
556 556
557void TEWidget::resizeEvent(QResizeEvent* ev) 557void TEWidget::resizeEvent(QResizeEvent* ev)
558{ 558{
559// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 559// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
560 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 560 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
561 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 561 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
562 //printf("curren: %d,%d\n",width(),height()); 562 //printf("curren: %d,%d\n",width(),height());
563HCNT("resizeEvent"); 563HCNT("resizeEvent");
564 564
565 // see comment in `paintEvent' concerning the rounding. 565 // see comment in `paintEvent' concerning the rounding.
566 //FIXME: could make a routine here; check width(),height() 566 //FIXME: could make a routine here; check width(),height()
567 assert(ev->size().width() == width()); 567 assert(ev->size().width() == width());
568 assert(ev->size().height() == height()); 568 assert(ev->size().height() == height());
569 569
570 propagateSize(); 570 propagateSize();
571} 571}
572 572
573void TEWidget::propagateSize() 573void TEWidget::propagateSize()
574{ 574{
575 ca* oldimg = image; 575 ca* oldimg = image;
576 int oldlin = lines; 576 int oldlin = lines;
577 int oldcol = columns; 577 int oldcol = columns;
578 makeImage(); 578 makeImage();
579 // we copy the old image to reduce flicker 579 // we copy the old image to reduce flicker
580 int lins = QMIN(oldlin,lines); 580 int lins = QMIN(oldlin,lines);
581 int cols = QMIN(oldcol,columns); 581 int cols = QMIN(oldcol,columns);
582 if (oldimg) 582 if (oldimg)
583 { 583 {
584 for (int lin = 0; lin < lins; lin++) 584 for (int lin = 0; lin < lins; lin++)
585 memcpy((void*)&image[columns*lin], 585 memcpy((void*)&image[columns*lin],
586 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 586 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
587 free(oldimg); //FIXME: try new,delete 587 free(oldimg); //FIXME: try new,delete
588 } 588 }
589 else 589 else
590 clearImage(); 590 clearImage();
591 591
592 //NOTE: control flows from the back through the chest right into the eye. 592 //NOTE: control flows from the back through the chest right into the eye.
593 // `emu' will call back via `setImage'. 593 // `emu' will call back via `setImage'.
594 594
595 resizing = TRUE; 595 resizing = TRUE;
596 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 596 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
597 resizing = FALSE; 597 resizing = FALSE;
598} 598}
599 599
600/* ------------------------------------------------------------------------- */ 600/* ------------------------------------------------------------------------- */
601/* */ 601/* */
602/* Scrollbar */ 602/* Scrollbar */
603/* */ 603/* */
604/* ------------------------------------------------------------------------- */ 604/* ------------------------------------------------------------------------- */
605 605
606void TEWidget::scrollChanged(int) { 606void TEWidget::scrollChanged(int) {
607 emit changedHistoryCursor(scrollbar->value()); //expose 607 emit changedHistoryCursor(scrollbar->value()); //expose
608} 608}
609 609
610void TEWidget::hScrollChanged(int loc) { 610void TEWidget::hScrollChanged(int loc) {
611 hposition = loc; 611 hposition = loc;
612 propagateSize(); 612 propagateSize();
613 update(); 613 update();
614 614
615// emit changedHorzCursor( hScrollbar->value()); //expose 615// emit changedHorzCursor( hScrollbar->value()); //expose
616} 616}
617 617
618void TEWidget::setScroll(int cursor, int slines) 618void TEWidget::setScroll(int cursor, int slines)
619{ 619{
620 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 620 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
621 scrollbar->setRange(0,slines); 621 scrollbar->setRange(0,slines);
622 scrollbar->setSteps(1,lines); 622 scrollbar->setSteps(1,lines);
623 scrollbar->setValue(cursor); 623 scrollbar->setValue(cursor);
624 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 624 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
625} 625}
626 626
627void TEWidget::setScrollbarLocation(int loc) 627void TEWidget::setScrollbarLocation(int loc)
628{ 628{
629 if (scrollLoc == loc) return; // quickly 629 if (scrollLoc == loc) return; // quickly
630 scrollLoc = loc; 630 scrollLoc = loc;
631 propagateSize(); 631 propagateSize();
632 update(); 632 update();
633} 633}
634 634
635/* ------------------------------------------------------------------------- */ 635/* ------------------------------------------------------------------------- */
636/* */ 636/* */
637/* Mouse */ 637/* Mouse */
638/* */ 638/* */
639/* ------------------------------------------------------------------------- */ 639/* ------------------------------------------------------------------------- */
640 640
641/*! 641/*!
642 Three different operations can be performed using the mouse, and the 642 Three different operations can be performed using the mouse, and the
643 routines in this section serve all of them: 643 routines in this section serve all of them:
644 644
645 1) The press/release events are exposed to the application 645 1) The press/release events are exposed to the application
646 2) Marking (press and move left button) and Pasting (press middle button) 646 2) Marking (press and move left button) and Pasting (press middle button)
647 3) The right mouse button is used from the configuration menu 647 3) The right mouse button is used from the configuration menu
648 648
649 NOTE: During the marking process we attempt to keep the cursor within 649 NOTE: During the marking process we attempt to keep the cursor within
650 the bounds of the text as being displayed by setting the mouse position 650 the bounds of the text as being displayed by setting the mouse position
651 whenever the mouse has left the text area. 651 whenever the mouse has left the text area.
652 652
653 Two reasons to do so: 653 Two reasons to do so:
654 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 654 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
655 Thus a `XGrapPointer' would have to be used instead. 655 Thus a `XGrapPointer' would have to be used instead.
656 2) Even if so, this would not help too much, since the text area 656 2) Even if so, this would not help too much, since the text area
657 of the TEWidget is normally not identical with it's bounds. 657 of the TEWidget is normally not identical with it's bounds.
658 658
659 The disadvantage of the current handling is, that the mouse can visibly 659 The disadvantage of the current handling is, that the mouse can visibly
660 leave the bounds of the widget and is then moved back. Because of the 660 leave the bounds of the widget and is then moved back. Because of the
661 current construction, and the reasons mentioned above, we cannot do better 661 current construction, and the reasons mentioned above, we cannot do better
662 without changing the overall construction. 662 without changing the overall construction.
663*/ 663*/
664 664
665/*! 665/*!
666*/ 666*/
667 667
668void TEWidget::mousePressEvent(QMouseEvent* ev) 668void TEWidget::mousePressEvent(QMouseEvent* ev)
669{ 669{
670//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 670//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
671 if ( !contentsRect().contains(ev->pos()) ) return; 671 if ( !contentsRect().contains(ev->pos()) ) return;
672 QPoint tL = contentsRect().topLeft(); 672 QPoint tL = contentsRect().topLeft();
673 int tLx = tL.x(); 673 int tLx = tL.x();
674 int tLy = tL.y(); 674 int tLy = tL.y();
675 675
676 word_selection_mode = FALSE; 676 word_selection_mode = FALSE;
677 677
678//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 678//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
679 if ( ev->button() == LeftButton) 679 if ( ev->button() == LeftButton)
680 { 680 {
681 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 681 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
682 682
683 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 683 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
684 684
685 if (mouse_marks || (ev->state() & ShiftButton)) 685 if (mouse_marks || (ev->state() & ShiftButton))
686 { 686 {
687 emit clearSelectionSignal(); 687 emit clearSelectionSignal();
688 iPntSel = pntSel = pos; 688 iPntSel = pntSel = pos;
689 actSel = 1; // left mouse button pressed but nothing selected yet. 689 actSel = 1; // left mouse button pressed but nothing selected yet.
690 grabMouse( /*crossCursor*/ ); // handle with care! 690 grabMouse( /*crossCursor*/ ); // handle with care!
691 } 691 }
692 else 692 else
693 { 693 {
694 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 694 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
695 } 695 }
696 } 696 }
697 if ( ev->button() == MidButton ) 697 if ( ev->button() == MidButton )
698 { 698 {
699 emitSelection(); 699 emitSelection();
700 } 700 }
701 if ( ev->button() == RightButton ) // Configure 701 if ( ev->button() == RightButton ) // Configure
702 { 702 {
703 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 703 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
704 } 704 }
705} 705}
706 706
707void TEWidget::mouseMoveEvent(QMouseEvent* ev) 707void TEWidget::mouseMoveEvent(QMouseEvent* ev)
708{ 708{
709 // for auto-hiding the cursor, we need mouseTracking 709 // for auto-hiding the cursor, we need mouseTracking
710 if (ev->state() == NoButton ) return; 710 if (ev->state() == NoButton ) return;
711 711
712 if (actSel == 0) return; 712 if (actSel == 0) return;
713 713
714 // don't extend selection while pasting 714 // don't extend selection while pasting
715 if (ev->state() & MidButton) return; 715 if (ev->state() & MidButton) return;
716 716
717 //if ( !contentsRect().contains(ev->pos()) ) return; 717 //if ( !contentsRect().contains(ev->pos()) ) return;
718 QPoint tL = contentsRect().topLeft(); 718 QPoint tL = contentsRect().topLeft();
719 int tLx = tL.x(); 719 int tLx = tL.x();
720 int tLy = tL.y(); 720 int tLy = tL.y();
721 int scroll = scrollbar->value(); 721 int scroll = scrollbar->value();
722// int hScroll = hScrollbar->value(); 722// int hScroll = hScrollbar->value();
723 723
724 // we're in the process of moving the mouse with the left button pressed 724 // we're in the process of moving the mouse with the left button pressed
725 // the mouse cursor will kept catched within the bounds of the text in 725 // the mouse cursor will kept catched within the bounds of the text in
726 // this widget. 726 // this widget.
727 727
728 // Adjust position within text area bounds. See FIXME above. 728 // Adjust position within text area bounds. See FIXME above.
729 QPoint pos = ev->pos(); 729 QPoint pos = ev->pos();
730 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 730 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
731 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 731 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
732 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 732 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
733 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 733 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
734 // check if we produce a mouse move event by this 734 // check if we produce a mouse move event by this
735 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 735 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
736 736
737 if ( pos.y() == tLy+bY+lines*font_h-1 ) 737 if ( pos.y() == tLy+bY+lines*font_h-1 )
738 { 738 {
739 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 739 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
740 } 740 }
741 if ( pos.y() == tLy+bY ) 741 if ( pos.y() == tLy+bY )
742 { 742 {
743 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 743 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
744 } 744 }
745 745
746 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 746 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
747 QPoint ohere; 747 QPoint ohere;
748 bool swapping = FALSE; 748 bool swapping = FALSE;
749 749
750 if ( word_selection_mode ) 750 if ( word_selection_mode )
751 { 751 {
752 // Extend to word boundaries 752 // Extend to word boundaries
753 int i; 753 int i;
754 int selClass; 754 int selClass;
755 755
756 bool left_not_right = ( here.y() < iPntSel.y() || 756 bool left_not_right = ( here.y() < iPntSel.y() ||
757 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 757 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
758 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 758 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
759 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 759 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
760 swapping = left_not_right != old_left_not_right; 760 swapping = left_not_right != old_left_not_right;
761 761
762 // Find left (left_not_right ? from here : from start) 762 // Find left (left_not_right ? from here : from start)
763 QPoint left = left_not_right ? here : iPntSel; 763 QPoint left = left_not_right ? here : iPntSel;
764 i = loc(left.x(),left.y()); 764 i = loc(left.x(),left.y());
765 selClass = charClass(image[i].c); 765 selClass = charClass(image[i].c);
766 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 766 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
767 { i--; left.rx()--; } 767 { i--; left.rx()--; }
768 768
769 // Find left (left_not_right ? from start : from here) 769 // Find left (left_not_right ? from start : from here)
770 QPoint right = left_not_right ? iPntSel : here; 770 QPoint right = left_not_right ? iPntSel : here;
771 i = loc(right.x(),right.y()); 771 i = loc(right.x(),right.y());
772 selClass = charClass(image[i].c); 772 selClass = charClass(image[i].c);
773 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 773 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
774 { i++; right.rx()++; } 774 { i++; right.rx()++; }
775 775
776 // Pick which is start (ohere) and which is extension (here) 776 // Pick which is start (ohere) and which is extension (here)
777 if ( left_not_right ) 777 if ( left_not_right )
778 { 778 {
779 here = left; ohere = right; 779 here = left; ohere = right;
780 } 780 }
781 else 781 else
782 { 782 {
783 here = right; ohere = left; 783 here = right; ohere = left;
784 } 784 }
785 } 785 }
786 786
787 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 787 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
788 788
789 if ( word_selection_mode ) { 789 if ( word_selection_mode ) {
790 if ( actSel < 2 || swapping ) { 790 if ( actSel < 2 || swapping ) {
791 emit beginSelectionSignal( ohere.x(), ohere.y() ); 791 emit beginSelectionSignal( ohere.x(), ohere.y() );
792 } 792 }
793 } else if ( actSel < 2 ) { 793 } else if ( actSel < 2 ) {
794 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 794 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
795 } 795 }
796 796
797 actSel = 2; // within selection 797 actSel = 2; // within selection
798 pntSel = here; 798 pntSel = here;
799 emit extendSelectionSignal( here.x(), here.y() ); 799 emit extendSelectionSignal( here.x(), here.y() );
800} 800}
801 801
802void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 802void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
803{ 803{
804//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 804//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
805 if ( ev->button() == LeftButton) 805 if ( ev->button() == LeftButton)
806 { 806 {
807 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 807 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
808 preserve_line_breaks = TRUE; 808 preserve_line_breaks = TRUE;
809 actSel = 0; 809 actSel = 0;
810 810
811 //FIXME: emits a release event even if the mouse is 811 //FIXME: emits a release event even if the mouse is
812 // outside the range. The procedure used in `mouseMoveEvent' 812 // outside the range. The procedure used in `mouseMoveEvent'
813 // applies here, too. 813 // applies here, too.
814 814
815 QPoint tL = contentsRect().topLeft(); 815 QPoint tL = contentsRect().topLeft();
816 int tLx = tL.x(); 816 int tLx = tL.x();
817 int tLy = tL.y(); 817 int tLy = tL.y();
818 818
819 if (!mouse_marks && !(ev->state() & ShiftButton)) 819 if (!mouse_marks && !(ev->state() & ShiftButton))
820 emit mouseSignal( 3, // release 820 emit mouseSignal( 3, // release
821 (ev->x()-tLx-blX)/font_w + 1, 821 (ev->x()-tLx-blX)/font_w + 1,
822 (ev->y()-tLy-bY)/font_h + 1 ); 822 (ev->y()-tLy-bY)/font_h + 1 );
823 releaseMouse(); 823 releaseMouse();
824 } 824 }
825} 825}
826 826
827void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 827void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
828{ 828{
829 if ( ev->button() != LeftButton) return; 829 if ( ev->button() != LeftButton) return;
830 830
831 QPoint tL = contentsRect().topLeft(); 831 QPoint tL = contentsRect().topLeft();
832 int tLx = tL.x(); 832 int tLx = tL.x();
833 int tLy = tL.y(); 833 int tLy = tL.y();
834 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 834 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
835 835
836 // pass on double click as two clicks. 836 // pass on double click as two clicks.
837 if (!mouse_marks && !(ev->state() & ShiftButton)) 837 if (!mouse_marks && !(ev->state() & ShiftButton))
838 { 838 {
839 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 839 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
840 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 840 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
841 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 841 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
842 return; 842 return;
843 } 843 }
844 844
845 845
846 emit clearSelectionSignal(); 846 emit clearSelectionSignal();
847 QPoint bgnSel = pos; 847 QPoint bgnSel = pos;
848 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 848 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
849 int i = loc(bgnSel.x(),bgnSel.y()); 849 int i = loc(bgnSel.x(),bgnSel.y());
850 iPntSel = bgnSel; 850 iPntSel = bgnSel;
851 851
852 word_selection_mode = TRUE; 852 word_selection_mode = TRUE;
853 853
854 // find word boundaries... 854 // find word boundaries...
855 int selClass = charClass(image[i].c); 855 int selClass = charClass(image[i].c);
856 { 856 {
857 // set the start... 857 // set the start...
858 int x = bgnSel.x(); 858 int x = bgnSel.x();
859 while ( x > 0 && charClass(image[i-1].c) == selClass ) 859 while ( x > 0 && charClass(image[i-1].c) == selClass )
860 { i--; x--; } 860 { i--; x--; }
861 bgnSel.setX(x); 861 bgnSel.setX(x);
862 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 862 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
863 863
864 // set the end... 864 // set the end...
865 i = loc( endSel.x(), endSel.y() ); 865 i = loc( endSel.x(), endSel.y() );
866 x = endSel.x(); 866 x = endSel.x();
867 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 867 while( x < columns-1 && charClass(image[i+1].c) == selClass )
868 { i++; x++ ; } 868 { i++; x++ ; }
869 endSel.setX(x); 869 endSel.setX(x);
870 actSel = 2; // within selection 870 actSel = 2; // within selection
871 emit extendSelectionSignal( endSel.x(), endSel.y() ); 871 emit extendSelectionSignal( endSel.x(), endSel.y() );
872 emit endSelectionSignal(preserve_line_breaks); 872 emit endSelectionSignal(preserve_line_breaks);
873 preserve_line_breaks = TRUE; 873 preserve_line_breaks = TRUE;
874 } 874 }
875} 875}
876 876
877void TEWidget::focusInEvent( QFocusEvent * ) 877void TEWidget::focusInEvent( QFocusEvent * )
878{ 878{
879 879
880 // do nothing, to prevent repainting 880 // do nothing, to prevent repainting
881} 881}
882 882
883 883
884void TEWidget::focusOutEvent( QFocusEvent * ) 884void TEWidget::focusOutEvent( QFocusEvent * )
885{ 885{
886 // do nothing, to prevent repainting 886 // do nothing, to prevent repainting
887} 887}
888 888
889bool TEWidget::focusNextPrevChild( bool next ) 889bool TEWidget::focusNextPrevChild( bool next )
890{ 890{
891 if (next) 891 if (next)
892 return false; // This disables changing the active part in konqueror 892 return false; // This disables changing the active part in konqueror
893 // when pressing Tab 893 // when pressing Tab
894 return QFrame::focusNextPrevChild( next ); 894 return QFrame::focusNextPrevChild( next );
895} 895}
896 896
897 897
898int TEWidget::charClass(char ch) const 898int TEWidget::charClass(char ch) const
899{ 899{
900 // This might seem like overkill, but imagine if ch was a Unicode 900 // This might seem like overkill, but imagine if ch was a Unicode
901 // character (Qt 2.0 QChar) - it might then be sensible to separate 901 // character (Qt 2.0 QChar) - it might then be sensible to separate
902 // the different language ranges, etc. 902 // the different language ranges, etc.
903 903
904 if ( isspace(ch) ) return ' '; 904 if ( isspace(ch) ) return ' ';
905 905
906 static const char *word_characters = ":@-./_~"; 906 static const char *word_characters = ":@-./_~";
907 if ( isalnum(ch) || strchr(word_characters, ch) ) 907 if ( isalnum(ch) || strchr(word_characters, ch) )
908 return 'a'; 908 return 'a';
909 909
910 // Everything else is weird 910 // Everything else is weird
911 return 1; 911 return 1;
912} 912}
913 913
914void TEWidget::setMouseMarks(bool on) 914void TEWidget::setMouseMarks(bool on)
915{ 915{
916 mouse_marks = on; 916 mouse_marks = on;
917 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 917 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
918} 918}
919 919
920/* ------------------------------------------------------------------------- */ 920/* ------------------------------------------------------------------------- */
921/* */ 921/* */
922/* Clipboard */ 922/* Clipboard */
923/* */ 923/* */
924/* ------------------------------------------------------------------------- */ 924/* ------------------------------------------------------------------------- */
925 925
926#undef KeyPress 926#undef KeyPress
927 927
928void TEWidget::emitSelection() 928void TEWidget::emitSelection()
929// Paste Clipboard by simulating keypress events 929// Paste Clipboard by simulating keypress events
930{ 930{
931#ifndef QT_NO_CLIPBOARD 931#ifndef QT_NO_CLIPBOARD
932 QString text = QApplication::clipboard()->text(); 932 QString text = QApplication::clipboard()->text();
933 if ( ! text.isNull() ) 933 if ( ! text.isNull() )
934 { 934 {
935 text.replace(QRegExp("\n"), "\r"); 935 text.replace(QRegExp("\n"), "\r");
936 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 936 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
937 emit keyPressedSignal(&e); // expose as a big fat keypress event 937 emit keyPressedSignal(&e); // expose as a big fat keypress event
938 emit clearSelectionSignal(); 938 emit clearSelectionSignal();
939 } 939 }
940#endif 940#endif
941} 941}
942 942
943void TEWidget::emitText(QString text) 943void TEWidget::emitText(QString text)
944{ 944{
945 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 945 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
946 emit keyPressedSignal(&e); // expose as a big fat keypress event 946 emit keyPressedSignal(&e); // expose as a big fat keypress event
947} 947}
948 948
949void TEWidget::pasteClipboard( ) 949void TEWidget::pasteClipboard( )
950{ 950{
951 emitSelection(); 951 emitSelection();
952} 952}
953 953
954void TEWidget::setSelection(const QString& t) 954void TEWidget::setSelection(const QString& t)
955{ 955{
956#ifndef QT_NO_CLIPBOARD 956#ifndef QT_NO_CLIPBOARD
957 // Disconnect signal while WE set the clipboard 957 // Disconnect signal while WE set the clipboard
958 QObject *cb = QApplication::clipboard(); 958 QObject *cb = QApplication::clipboard();
959 QObject::disconnect( cb, SIGNAL(dataChanged()), 959 QObject::disconnect( cb, SIGNAL(dataChanged()),
960 this, SLOT(onClearSelection()) ); 960 this, SLOT(onClearSelection()) );
961 961
962 QApplication::clipboard()->setText(t); 962 QApplication::clipboard()->setText(t);
963 963
964 QObject::connect( cb, SIGNAL(dataChanged()), 964 QObject::connect( cb, SIGNAL(dataChanged()),
965 this, SLOT(onClearSelection()) ); 965 this, SLOT(onClearSelection()) );
966#endif 966#endif
967} 967}
968 968
969void TEWidget::onClearSelection() 969void TEWidget::onClearSelection()
970{ 970{
971 emit clearSelectionSignal(); 971 emit clearSelectionSignal();
972} 972}
973 973
974/* ------------------------------------------------------------------------- */ 974/* ------------------------------------------------------------------------- */
975/* */ 975/* */
976/* Keyboard */ 976/* Keyboard */
977/* */ 977/* */
978/* ------------------------------------------------------------------------- */ 978/* ------------------------------------------------------------------------- */
979 979
980//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 980//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
981// due to a bug in `QT' or the ignorance of the author to prevent 981// due to a bug in `QT' or the ignorance of the author to prevent
982// repaint events being emitted to the screen whenever one leaves 982// repaint events being emitted to the screen whenever one leaves
983// or reenters the screen to/from another application. 983// or reenters the screen to/from another application.
984// 984//
985// Troll says one needs to change focusInEvent() and focusOutEvent(), 985// Troll says one needs to change focusInEvent() and focusOutEvent(),
986// which would also let you have an in-focus cursor and an out-focus 986// which would also let you have an in-focus cursor and an out-focus
987// cursor like xterm does. 987// cursor like xterm does.
988 988
989// for the auto-hide cursor feature, I added empty focusInEvent() and 989// for the auto-hide cursor feature, I added empty focusInEvent() and
990// focusOutEvent() so that update() isn't called. 990// focusOutEvent() so that update() isn't called.
991// For auto-hide, we need to get keypress-events, but we only get them when 991// For auto-hide, we need to get keypress-events, but we only get them when
992// we have focus. 992// we have focus.
993 993
994void TEWidget::doScroll(int lines) 994void TEWidget::doScroll(int lines)
995{ 995{
996 scrollbar->setValue(scrollbar->value()+lines); 996 scrollbar->setValue(scrollbar->value()+lines);
997} 997}
998 998
999void TEWidget::doHScroll(int lines) { 999void TEWidget::doHScroll(int lines) {
1000 hScrollbar->setValue( hScrollbar->value()+lines); 1000 hScrollbar->setValue( hScrollbar->value()+lines);
1001} 1001}
1002 1002
1003bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1003bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1004{ 1004{
1005 if ( (e->type() == QEvent::Accel || 1005 if ( (e->type() == QEvent::Accel ||
1006 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1006 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1007 static_cast<QKeyEvent *>( e )->ignore(); 1007 static_cast<QKeyEvent *>( e )->ignore();
1008 return true; 1008 return true;
1009 } 1009 }
1010 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1010 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1011 return FALSE; // not us 1011 return FALSE; // not us
1012 if ( e->type() == QEvent::Wheel) { 1012 if ( e->type() == QEvent::Wheel) {
1013 QApplication::sendEvent(scrollbar, e); 1013 QApplication::sendEvent(scrollbar, e);
1014 } 1014 }
1015 1015
1016#ifdef FAKE_CTRL_AND_ALT 1016#ifdef FAKE_CTRL_AND_ALT
1017 static bool control = FALSE; 1017 static bool control = FALSE;
1018 static bool alt = FALSE; 1018 static bool alt = FALSE;
1019// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1019// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1020 bool dele=FALSE; 1020 bool dele=FALSE;
1021 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1021 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1022 QKeyEvent* ke = (QKeyEvent*)e; 1022 QKeyEvent* ke = (QKeyEvent*)e;
1023 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1023 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1024 switch (ke->key()) { 1024 switch (ke->key()) {
1025 case Key_F9: // let this be "Control" 1025 case Key_F9: // let this be "Control"
1026 control = keydown; 1026 control = keydown;
1027 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1027 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1028 dele=TRUE; 1028 dele=TRUE;
1029 break; 1029 break;
1030 case Key_F13: // let this be "Alt" 1030 case Key_F13: // let this be "Alt"
1031 alt = keydown; 1031 alt = keydown;
1032 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1032 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1033 dele=TRUE; 1033 dele=TRUE;
1034 break; 1034 break;
1035 default: 1035 default:
1036 if ( control ) { 1036 if ( control ) {
1037 int a = toupper(ke->ascii())-64; 1037 int a = toupper(ke->ascii())-64;
1038 if ( a >= 0 && a < ' ' ) { 1038 if ( a >= 0 && a < ' ' ) {
1039 e = new QKeyEvent(e->type(), ke->key(), 1039 e = new QKeyEvent(e->type(), ke->key(),
1040 a, ke->state()|ControlButton, QChar(a,0)); 1040 a, ke->state()|ControlButton, QChar(a,0));
1041 dele=TRUE; 1041 dele=TRUE;
1042 } 1042 }
1043 } 1043 }
1044 if ( alt ) { 1044 if ( alt ) {
1045 e = new QKeyEvent(e->type(), ke->key(), 1045 e = new QKeyEvent(e->type(), ke->key(),
1046 ke->ascii(), ke->state()|AltButton, ke->text()); 1046 ke->ascii(), ke->state()|AltButton, ke->text());
1047 dele=TRUE; 1047 dele=TRUE;
1048 } 1048 }
1049 } 1049 }
1050 } 1050 }
1051#endif 1051#endif
1052 1052
1053 if ( e->type() == QEvent::KeyPress ) { 1053 if ( e->type() == QEvent::KeyPress ) {
1054 QKeyEvent* ke = (QKeyEvent*)e; 1054 QKeyEvent* ke = (QKeyEvent*)e;
1055 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1055 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1056 // know where the current selection is. 1056 // know where the current selection is.
1057 1057
1058// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); 1058// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state());
1059 1059
1060 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { 1060 if( ke->state() == ShiftButton && ke->key() == Key_Tab) {
1061 //lets hardcode this sucker 1061 //lets hardcode this sucker
1062 1062
1063// qDebug("key pressed 2 is 0x%x", ke->key()); 1063// qDebug("key pressed 2 is 0x%x", ke->key());
1064 emitText("\\"); // expose 1064 emitText("\\"); // expose
1065 } 1065 }
1066 else if( ke->state() == ControlButton && ke->key() == Key_V) { 1066 else if( ke->state() == ControlButton && ke->key() == Key_V) {
1067 pasteClipboard(); 1067 pasteClipboard();
1068 } 1068 }
1069 else 1069 else
1070 emit keyPressedSignal(ke); // expose 1070 emit keyPressedSignal(ke); // expose
1071 ke->accept(); 1071 ke->accept();
1072#ifdef FAKE_CTRL_AND_ALT 1072#ifdef FAKE_CTRL_AND_ALT
1073 if ( dele ) delete e; 1073 if ( dele ) delete e;
1074#endif 1074#endif
1075 return true; // stop the event 1075 return true; // stop the event
1076 } 1076 }
1077 if ( e->type() == QEvent::Enter ) { 1077 if ( e->type() == QEvent::Enter ) {
1078 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1078 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1079 this, SLOT(onClearSelection()) ); 1079 this, SLOT(onClearSelection()) );
1080 } 1080 }
1081 if ( e->type() == QEvent::Leave ) { 1081 if ( e->type() == QEvent::Leave ) {
1082 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1082 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1083 this, SLOT(onClearSelection()) ); 1083 this, SLOT(onClearSelection()) );
1084 } 1084 }
1085 return QFrame::eventFilter( obj, e ); 1085 return QFrame::eventFilter( obj, e );
1086} 1086}
1087 1087
1088/* ------------------------------------------------------------------------- */ 1088/* ------------------------------------------------------------------------- */
1089/* */ 1089/* */
1090/* Frame */ 1090/* Frame */
1091/* */ 1091/* */
1092/* ------------------------------------------------------------------------- */ 1092/* ------------------------------------------------------------------------- */
1093 1093
1094void TEWidget::frameChanged() 1094void TEWidget::frameChanged()
1095{ 1095{
1096 propagateSize(); 1096 propagateSize();
1097 update(); 1097 update();
1098} 1098}
1099 1099
1100/* ------------------------------------------------------------------------- */ 1100/* ------------------------------------------------------------------------- */
1101/* */ 1101/* */
1102/* Sound */ 1102/* Sound */
1103/* */ 1103/* */
1104/* ------------------------------------------------------------------------- */ 1104/* ------------------------------------------------------------------------- */
1105 1105
1106void TEWidget::Bell() 1106void TEWidget::Bell()
1107{ 1107{
1108//#ifdef QT_QWS_CUSTOM 1108//#ifdef QT_QWS_SHARP
1109//# ifndef QT_NO_COP 1109//# ifndef QT_NO_COP
1110 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); 1110 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
1111//# endif 1111//# endif
1112//#else 1112//#else
1113//# ifndef QT_NO_SOUND 1113//# ifndef QT_NO_SOUND
1114// QSound::play(Resource::findSound("alarm")); 1114// QSound::play(Resource::findSound("alarm"));
1115//# endif 1115//# endif
1116//#endif 1116//#endif
1117 1117
1118// QApplication::beep(); 1118// QApplication::beep();
1119} 1119}
1120 1120
1121/* ------------------------------------------------------------------------- */ 1121/* ------------------------------------------------------------------------- */
1122/* */ 1122/* */
1123/* Auxiluary */ 1123/* Auxiluary */
1124/* */ 1124/* */
1125/* ------------------------------------------------------------------------- */ 1125/* ------------------------------------------------------------------------- */
1126 1126
1127void TEWidget::clearImage() 1127void TEWidget::clearImage()
1128// initialize the image 1128// initialize the image
1129// for internal use only 1129// for internal use only
1130{ 1130{
1131 for (int y = 0; y < lines; y++) 1131 for (int y = 0; y < lines; y++)
1132 for (int x = 0; x < columns; x++) 1132 for (int x = 0; x < columns; x++)
1133 { 1133 {
1134 image[loc(x,y)].c = 0xff; //' '; 1134 image[loc(x,y)].c = 0xff; //' ';
1135 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1135 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1136 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1136 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1137 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1137 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1138 } 1138 }
1139} 1139}
1140 1140
1141// Create Image /////////////////////////////////////////////////////// 1141// Create Image ///////////////////////////////////////////////////////
1142 1142
1143void TEWidget::calcGeometry() 1143void TEWidget::calcGeometry()
1144{ 1144{
1145 int showhscrollbar = 1; 1145 int showhscrollbar = 1;
1146 int hwidth = 0; 1146 int hwidth = 0;
1147 int dcolumns; 1147 int dcolumns;
1148 Config cfg("Konsole"); 1148 Config cfg("Konsole");
1149 cfg.setGroup("ScrollBar"); 1149 cfg.setGroup("ScrollBar");
1150 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 1150 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
1151 1151
1152 if(vcolumns == 0) showhscrollbar = 0; 1152 if(vcolumns == 0) showhscrollbar = 0;
1153 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1153 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1154 1154
1155 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1155 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1156 contentsRect().height() - hwidth); 1156 contentsRect().height() - hwidth);
1157 1157
1158 switch(scrollLoc) { 1158 switch(scrollLoc) {
1159 case SCRNONE : 1159 case SCRNONE :
1160 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1160 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1161 dcolumns = columns; 1161 dcolumns = columns;
1162 if(vcolumns) columns = vcolumns; 1162 if(vcolumns) columns = vcolumns;
1163 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1163 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1164 if(showhscrollbar) 1164 if(showhscrollbar)
1165 blX = -hposition * font_w; 1165 blX = -hposition * font_w;
1166 brX = blX; 1166 brX = blX;
1167 scrollbar->hide(); 1167 scrollbar->hide();
1168 break; 1168 break;
1169 case SCRLEFT : 1169 case SCRLEFT :
1170 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1170 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1171 dcolumns = columns; 1171 dcolumns = columns;
1172 if(vcolumns) columns = vcolumns; 1172 if(vcolumns) columns = vcolumns;
1173 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1173 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1174 if(showhscrollbar) 1174 if(showhscrollbar)
1175 brX = -hposition * font_w; 1175 brX = -hposition * font_w;
1176 blX = brX + scrollbar->width(); 1176 blX = brX + scrollbar->width();
1177 scrollbar->move(contentsRect().topLeft()); 1177 scrollbar->move(contentsRect().topLeft());
1178 scrollbar->show(); 1178 scrollbar->show();
1179 break; 1179 break;
1180 case SCRRIGHT: 1180 case SCRRIGHT:
1181 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1181 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1182 dcolumns = columns; 1182 dcolumns = columns;
1183 if(vcolumns) columns = vcolumns; 1183 if(vcolumns) columns = vcolumns;
1184 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1184 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1185 if(showhscrollbar) 1185 if(showhscrollbar)
1186 blX = -hposition * font_w; 1186 blX = -hposition * font_w;
1187 brX = blX; 1187 brX = blX;
1188 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1188 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1189 scrollbar->show(); 1189 scrollbar->show();
1190 break; 1190 break;
1191 } 1191 }
1192 //FIXME: support 'rounding' styles 1192 //FIXME: support 'rounding' styles
1193 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1193 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1194 bY = (contentsRect().height() - (lines *font_h)) / 2; 1194 bY = (contentsRect().height() - (lines *font_h)) / 2;
1195 1195
1196 if(showhscrollbar == 1) { 1196 if(showhscrollbar == 1) {
1197 hScrollbar->resize(contentsRect().width() - hwidth, hwidth); 1197 hScrollbar->resize(contentsRect().width() - hwidth, hwidth);
1198 hScrollbar->setRange(0, vcolumns - dcolumns); 1198 hScrollbar->setRange(0, vcolumns - dcolumns);
1199 1199
1200 QPoint p = contentsRect().bottomLeft(); 1200 QPoint p = contentsRect().bottomLeft();
1201 hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1201 hScrollbar->move(QPoint(p.x(), p.y() - hwidth));
1202 hScrollbar->show(); 1202 hScrollbar->show();
1203 } 1203 }
1204 else hScrollbar->hide(); 1204 else hScrollbar->hide();
1205 1205
1206 if(showhscrollbar == 1) { 1206 if(showhscrollbar == 1) {
1207 lines = lines - (hwidth / font_h) - 1; 1207 lines = lines - (hwidth / font_h) - 1;
1208 if(lines < 1) lines = 1; 1208 if(lines < 1) lines = 1;
1209 } 1209 }
1210 //FIXME: support 'rounding' styles 1210 //FIXME: support 'rounding' styles
1211} 1211}
1212 1212
1213void TEWidget::makeImage() 1213void TEWidget::makeImage()
1214//FIXME: rename 'calcGeometry? 1214//FIXME: rename 'calcGeometry?
1215{ 1215{
1216 calcGeometry(); 1216 calcGeometry();
1217 image = (ca*) malloc(lines*columns*sizeof(ca)); 1217 image = (ca*) malloc(lines*columns*sizeof(ca));
1218 clearImage(); 1218 clearImage();
1219} 1219}
1220 1220
1221// calculate the needed size 1221// calculate the needed size
1222QSize TEWidget::calcSize(int cols, int lins) const 1222QSize TEWidget::calcSize(int cols, int lins) const
1223{ 1223{
1224 int frw = width() - contentsRect().width(); 1224 int frw = width() - contentsRect().width();
1225 int frh = height() - contentsRect().height(); 1225 int frh = height() - contentsRect().height();
1226 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1226 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1227 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1227 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1228} 1228}
1229 1229
1230QSize TEWidget::sizeHint() const 1230QSize TEWidget::sizeHint() const
1231{ 1231{
1232 return size(); 1232 return size();
1233} 1233}
1234 1234
1235void TEWidget::styleChange(QStyle &) 1235void TEWidget::styleChange(QStyle &)
1236{ 1236{
1237 propagateSize(); 1237 propagateSize();
1238} 1238}
1239 1239
1240#ifndef QT_NO_DRAGANDDROP 1240#ifndef QT_NO_DRAGANDDROP
1241 1241
1242/* --------------------------------------------------------------------- */ 1242/* --------------------------------------------------------------------- */
1243/* */ 1243/* */
1244/* Drag & Drop */ 1244/* Drag & Drop */
1245/* */ 1245/* */
1246/* --------------------------------------------------------------------- */ 1246/* --------------------------------------------------------------------- */
1247 1247
1248 1248
1249void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1249void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1250{ 1250{
1251 e->accept(QTextDrag::canDecode(e) || 1251 e->accept(QTextDrag::canDecode(e) ||
1252 QUriDrag::canDecode(e)); 1252 QUriDrag::canDecode(e));
1253} 1253}
1254 1254
1255void TEWidget::dropEvent(QDropEvent* event) 1255void TEWidget::dropEvent(QDropEvent* event)
1256{ 1256{
1257 // The current behaviour when url(s) are dropped is 1257 // The current behaviour when url(s) are dropped is
1258 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1258 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1259 // * in all other cases, just paste 1259 // * in all other cases, just paste
1260 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1260 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1261 QStrList strlist; 1261 QStrList strlist;
1262 int file_count = 0; 1262 int file_count = 0;
1263 dropText = ""; 1263 dropText = "";
1264 bool bPopup = true; 1264 bool bPopup = true;
1265 1265
1266 if(QUriDrag::decode(event, strlist)) { 1266 if(QUriDrag::decode(event, strlist)) {
1267 if (strlist.count()) { 1267 if (strlist.count()) {
1268 for(const char* p = strlist.first(); p; p = strlist.next()) { 1268 for(const char* p = strlist.first(); p; p = strlist.next()) {
1269 if(file_count++ > 0) { 1269 if(file_count++ > 0) {
1270 dropText += " "; 1270 dropText += " ";
1271 bPopup = false; // more than one file, don't popup 1271 bPopup = false; // more than one file, don't popup
1272 } 1272 }
1273 1273
1274/* 1274/*
1275 KURL url(p); 1275 KURL url(p);
1276 if (url.isLocalFile()) { 1276 if (url.isLocalFile()) {
1277 dropText += url.path(); // local URL : remove protocol 1277 dropText += url.path(); // local URL : remove protocol
1278 } 1278 }
1279 else { 1279 else {
1280 dropText += url.prettyURL(); 1280 dropText += url.prettyURL();
1281 bPopup = false; // a non-local file, don't popup 1281 bPopup = false; // a non-local file, don't popup
1282 } 1282 }
1283*/ 1283*/
1284 1284
1285 } 1285 }
1286 1286
1287 if (bPopup) 1287 if (bPopup)
1288 // m_drop->popup(pos() + event->pos()); 1288 // m_drop->popup(pos() + event->pos());
1289 m_drop->popup(mapToGlobal(event->pos())); 1289 m_drop->popup(mapToGlobal(event->pos()));
1290 else 1290 else
1291 { 1291 {
1292 if (currentSession) { 1292 if (currentSession) {
1293 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1293 currentSession->getEmulation()->sendString(dropText.local8Bit());
1294 } 1294 }
1295// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1295// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1296 } 1296 }
1297 } 1297 }
1298 } 1298 }
1299 else if(QTextDrag::decode(event, dropText)) { 1299 else if(QTextDrag::decode(event, dropText)) {
1300// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1300// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1301 if (currentSession) { 1301 if (currentSession) {
1302 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1302 currentSession->getEmulation()->sendString(dropText.local8Bit());
1303 } 1303 }
1304 // Paste it 1304 // Paste it
1305 } 1305 }
1306} 1306}
1307#endif 1307#endif
1308 1308
1309 1309
1310void TEWidget::drop_menu_activated(int item) 1310void TEWidget::drop_menu_activated(int item)
1311{ 1311{
1312#ifndef QT_NO_DRAGANDDROP 1312#ifndef QT_NO_DRAGANDDROP
1313 switch (item) 1313 switch (item)
1314 { 1314 {
1315 case 0: // paste 1315 case 0: // paste
1316 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1316 currentSession->getEmulation()->sendString(dropText.local8Bit());
1317// KWM::activate((Window)this->winId()); 1317// KWM::activate((Window)this->winId());
1318 break; 1318 break;
1319 case 1: // cd ... 1319 case 1: // cd ...
1320 currentSession->getEmulation()->sendString("cd "); 1320 currentSession->getEmulation()->sendString("cd ");
1321 struct stat statbuf; 1321 struct stat statbuf;
1322 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1322 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1323 { 1323 {
1324 if ( !S_ISDIR(statbuf.st_mode) ) 1324 if ( !S_ISDIR(statbuf.st_mode) )
1325 { 1325 {
1326/* 1326/*
1327 KURL url; 1327 KURL url;
1328 url.setPath( dropText ); 1328 url.setPath( dropText );
1329 dropText = url.directory( true, false ); // remove filename 1329 dropText = url.directory( true, false ); // remove filename
1330*/ 1330*/
1331 } 1331 }
1332 } 1332 }
1333 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1333 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1334 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1334 currentSession->getEmulation()->sendString(dropText.local8Bit());
1335 currentSession->getEmulation()->sendString("\n"); 1335 currentSession->getEmulation()->sendString("\n");
1336// KWM::activate((Window)this->winId()); 1336// KWM::activate((Window)this->winId());
1337 break; 1337 break;
1338 } 1338 }
1339#endif 1339#endif
1340} 1340}
1341 1341
1342void TEWidget::setWrapAt(int columns) 1342void TEWidget::setWrapAt(int columns)
1343{ 1343{
1344 vcolumns = columns; 1344 vcolumns = columns;
1345 propagateSize(); 1345 propagateSize();
1346 update(); 1346 update();
1347} 1347}
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index f2e00d8..3e8c731 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,920 +1,920 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "qcopbridge.h" 24#include "qcopbridge.h"
25#include "shutdownimpl.h" 25#include "shutdownimpl.h"
26#include "startmenu.h" 26#include "startmenu.h"
27#include "taskbar.h" 27#include "taskbar.h"
28#include "transferserver.h" 28#include "transferserver.h"
29#include "irserver.h" 29#include "irserver.h"
30#include "packageslave.h" 30#include "packageslave.h"
31#include "screensaver.h" 31#include "screensaver.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/network.h> 40#include <qpe/network.h>
41#include <qpe/global.h> 41#include <qpe/global.h>
42 42
43#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 43#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ )
44#include <qpe/custom.h> 44#include <qpe/custom.h>
45#endif 45#endif
46 46
47#include <opie/odevice.h> 47#include <opie/odevice.h>
48 48
49#include <qgfx_qws.h> 49#include <qgfx_qws.h>
50#include <qmainwindow.h> 50#include <qmainwindow.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qwindowsystem_qws.h> 53#include <qwindowsystem_qws.h>
54 54
55#include <qvaluelist.h> 55#include <qvaluelist.h>
56 56
57#include <stdlib.h> 57#include <stdlib.h>
58#include <unistd.h> 58#include <unistd.h>
59#include <fcntl.h> 59#include <fcntl.h>
60 60
61using namespace Opie; 61using namespace Opie;
62 62
63class QCopKeyRegister 63class QCopKeyRegister
64{ 64{
65public: 65public:
66 QCopKeyRegister() : keyCode( 0 ) 66 QCopKeyRegister() : keyCode( 0 )
67 { } 67 { }
68 QCopKeyRegister( int k, const QString &c, const QString &m ) 68 QCopKeyRegister( int k, const QString &c, const QString &m )
69 : keyCode( k ), channel( c ), message( m ) 69 : keyCode( k ), channel( c ), message( m )
70 { } 70 { }
71 71
72 int getKeyCode() const 72 int getKeyCode() const
73 { 73 {
74 return keyCode; 74 return keyCode;
75 } 75 }
76 QString getChannel() const 76 QString getChannel() const
77 { 77 {
78 return channel; 78 return channel;
79 } 79 }
80 QString getMessage() const 80 QString getMessage() const
81 { 81 {
82 return message; 82 return message;
83 } 83 }
84 84
85private: 85private:
86 int keyCode; 86 int keyCode;
87 QString channel, message; 87 QString channel, message;
88}; 88};
89 89
90typedef QValueList<QCopKeyRegister> KeyRegisterList; 90typedef QValueList<QCopKeyRegister> KeyRegisterList;
91KeyRegisterList keyRegisterList; 91KeyRegisterList keyRegisterList;
92 92
93static Desktop* qpedesktop = 0; 93static Desktop* qpedesktop = 0;
94static int loggedin = 0; 94static int loggedin = 0;
95static void login( bool at_poweron ) 95static void login( bool at_poweron )
96{ 96{
97 if ( !loggedin ) { 97 if ( !loggedin ) {
98 Global::terminateBuiltin( "calibrate" ); 98 Global::terminateBuiltin( "calibrate" );
99 Password::authenticate( at_poweron ); 99 Password::authenticate( at_poweron );
100 loggedin = 1; 100 loggedin = 1;
101 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 101 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
102 } 102 }
103} 103}
104 104
105bool Desktop::screenLocked() 105bool Desktop::screenLocked()
106{ 106{
107 return loggedin == 0; 107 return loggedin == 0;
108} 108}
109 109
110/* 110/*
111 Priority is number of alerts that are needed to pop up 111 Priority is number of alerts that are needed to pop up
112 alert. 112 alert.
113 */ 113 */
114class DesktopPowerAlerter : public QMessageBox 114class DesktopPowerAlerter : public QMessageBox
115{ 115{
116public: 116public:
117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
118 : QMessageBox( tr( "Battery Status" ), "Low Battery", 118 : QMessageBox( tr( "Battery Status" ), "Low Battery",
119 QMessageBox::Critical, 119 QMessageBox::Critical,
120 QMessageBox::Ok | QMessageBox::Default, 120 QMessageBox::Ok | QMessageBox::Default,
121 QMessageBox::NoButton, QMessageBox::NoButton, 121 QMessageBox::NoButton, QMessageBox::NoButton,
122 parent, name, FALSE ) 122 parent, name, FALSE )
123 { 123 {
124 currentPriority = INT_MAX; 124 currentPriority = INT_MAX;
125 alertCount = 0; 125 alertCount = 0;
126 } 126 }
127 127
128 void alert( const QString &text, int priority ); 128 void alert( const QString &text, int priority );
129 void hideEvent( QHideEvent * ); 129 void hideEvent( QHideEvent * );
130private: 130private:
131 int currentPriority; 131 int currentPriority;
132 int alertCount; 132 int alertCount;
133}; 133};
134 134
135void DesktopPowerAlerter::alert( const QString &text, int priority ) 135void DesktopPowerAlerter::alert( const QString &text, int priority )
136{ 136{
137 alertCount++; 137 alertCount++;
138 if ( alertCount < priority ) 138 if ( alertCount < priority )
139 return ; 139 return ;
140 if ( priority > currentPriority ) 140 if ( priority > currentPriority )
141 return ; 141 return ;
142 currentPriority = priority; 142 currentPriority = priority;
143 setText( text ); 143 setText( text );
144 show(); 144 show();
145} 145}
146 146
147 147
148void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 148void DesktopPowerAlerter::hideEvent( QHideEvent *e )
149{ 149{
150 QMessageBox::hideEvent( e ); 150 QMessageBox::hideEvent( e );
151 alertCount = 0; 151 alertCount = 0;
152 currentPriority = INT_MAX; 152 currentPriority = INT_MAX;
153} 153}
154 154
155 155
156void DesktopApplication::switchLCD ( bool on ) 156void DesktopApplication::switchLCD ( bool on )
157{ 157{
158 if ( qApp ) { 158 if ( qApp ) {
159 DesktopApplication *dapp = (DesktopApplication *) qApp; 159 DesktopApplication *dapp = (DesktopApplication *) qApp;
160 160
161 if ( dapp-> m_screensaver ) { 161 if ( dapp-> m_screensaver ) {
162 if ( on ) { 162 if ( on ) {
163 dapp-> m_screensaver-> setDisplayState ( true ); 163 dapp-> m_screensaver-> setDisplayState ( true );
164 dapp-> m_screensaver-> setBacklight ( -3 ); 164 dapp-> m_screensaver-> setBacklight ( -3 );
165 } 165 }
166 else { 166 else {
167 dapp-> m_screensaver-> setDisplayState ( false ); 167 dapp-> m_screensaver-> setDisplayState ( false );
168 } 168 }
169 } 169 }
170 } 170 }
171} 171}
172 172
173 173
174DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 174DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
175 : QPEApplication( argc, argv, appType ) 175 : QPEApplication( argc, argv, appType )
176{ 176{
177 177
178 Config cfg( "apm" ); 178 Config cfg( "apm" );
179 cfg.setGroup( "Warnings" ); 179 cfg.setGroup( "Warnings" );
180 //cfg.readNumEntry( "checkinterval", 10000 ) 180 //cfg.readNumEntry( "checkinterval", 10000 )
181 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); 181 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
182 m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); 182 m_powerCritical = cfg.readNumEntry( "powercritical", 5 );
183 183
184 m_ps = new PowerStatus; 184 m_ps = new PowerStatus;
185 m_ps_last = new PowerStatus; 185 m_ps_last = new PowerStatus;
186 pa = new DesktopPowerAlerter( 0 ); 186 pa = new DesktopPowerAlerter( 0 );
187 187
188 m_timer = new QTimer( this ); 188 m_timer = new QTimer( this );
189 connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); 189 connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) );
190 m_timer->start( 5000 ); 190 m_timer->start( 5000 );
191 191
192 channel = new QCopChannel( "QPE/Desktop", this ); 192 channel = new QCopChannel( "QPE/Desktop", this );
193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
194 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 194 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
195 195
196 channel = new QCopChannel( "QPE/System", this ); 196 channel = new QCopChannel( "QPE/System", this );
197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
198 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 198 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
199 199
200 m_screensaver = new OpieScreenSaver ( ); 200 m_screensaver = new OpieScreenSaver ( );
201 m_screensaver-> setInterval ( -1 ); 201 m_screensaver-> setInterval ( -1 );
202 QWSServer::setScreenSaver( m_screensaver ); 202 QWSServer::setScreenSaver( m_screensaver );
203 203
204 apmTimeout ( ); 204 apmTimeout ( );
205} 205}
206 206
207 207
208DesktopApplication::~DesktopApplication() 208DesktopApplication::~DesktopApplication()
209{ 209{
210 delete m_ps; 210 delete m_ps;
211 delete m_ps_last; 211 delete m_ps_last;
212 delete pa; 212 delete pa;
213} 213}
214 214
215void DesktopApplication::apmTimeout() 215void DesktopApplication::apmTimeout()
216{ 216{
217 qpedesktop->checkMemory(); // in case no events are being generated 217 qpedesktop->checkMemory(); // in case no events are being generated
218 218
219 *m_ps_last = *m_ps; 219 *m_ps_last = *m_ps;
220 *m_ps = PowerStatusManager::readStatus(); 220 *m_ps = PowerStatusManager::readStatus();
221 221
222 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) 222 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( ))
223 m_screensaver-> powerStatusChanged ( *m_ps ); 223 m_screensaver-> powerStatusChanged ( *m_ps );
224 224
225 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { 225 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) {
226 int bat = m_ps-> batteryPercentRemaining ( ); 226 int bat = m_ps-> batteryPercentRemaining ( );
227 227
228 if ( bat < m_ps_last-> batteryPercentRemaining ( )) { 228 if ( bat < m_ps_last-> batteryPercentRemaining ( )) {
229 if ( bat <= m_powerCritical ) 229 if ( bat <= m_powerCritical )
230 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 230 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 );
231 else if ( bat <= m_powerVeryLow ) 231 else if ( bat <= m_powerVeryLow )
232 pa->alert( tr( "Battery is running very low." ), 2 ); 232 pa->alert( tr( "Battery is running very low." ), 2 );
233 } 233 }
234 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) 234 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow )
235 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); 235 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 );
236 } 236 }
237} 237}
238 238
239void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 239void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
240{ 240{
241 QDataStream stream( data, IO_ReadOnly ); 241 QDataStream stream( data, IO_ReadOnly );
242 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 242 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
243 int k; 243 int k;
244 QString c, m; 244 QString c, m;
245 stream >> k; 245 stream >> k;
246 stream >> c; 246 stream >> c;
247 stream >> m; 247 stream >> m;
248 248
249 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 249 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
250 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 250 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
251 } 251 }
252} 252}
253 253
254 254
255void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 255void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
256{ 256{
257 QDataStream stream ( data, IO_ReadOnly ); 257 QDataStream stream ( data, IO_ReadOnly );
258 258
259 if ( msg == "setScreenSaverInterval(int)" ) { 259 if ( msg == "setScreenSaverInterval(int)" ) {
260 int time; 260 int time;
261 stream >> time; 261 stream >> time;
262 m_screensaver-> setInterval( time ); 262 m_screensaver-> setInterval( time );
263 } 263 }
264 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 264 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
265 int t1, t2, t3; 265 int t1, t2, t3;
266 stream >> t1 >> t2 >> t3; 266 stream >> t1 >> t2 >> t3;
267 m_screensaver-> setIntervals( t1, t2, t3 ); 267 m_screensaver-> setIntervals( t1, t2, t3 );
268 } 268 }
269 else if ( msg == "setBacklight(int)" ) { 269 else if ( msg == "setBacklight(int)" ) {
270 int bright; 270 int bright;
271 stream >> bright; 271 stream >> bright;
272 m_screensaver-> setBacklight( bright ); 272 m_screensaver-> setBacklight( bright );
273 } 273 }
274 else if ( msg == "setScreenSaverMode(int)" ) { 274 else if ( msg == "setScreenSaverMode(int)" ) {
275 int mode; 275 int mode;
276 stream >> mode; 276 stream >> mode;
277 m_screensaver-> setMode ( mode ); 277 m_screensaver-> setMode ( mode );
278 } 278 }
279 else if ( msg == "reloadPowerWarnSettings()" ) { 279 else if ( msg == "reloadPowerWarnSettings()" ) {
280 reloadPowerWarnSettings(); 280 reloadPowerWarnSettings();
281 } 281 }
282 else if ( msg == "setDisplayState(int)" ) { 282 else if ( msg == "setDisplayState(int)" ) {
283 int state; 283 int state;
284 stream >> state; 284 stream >> state;
285 m_screensaver-> setDisplayState ( state != 0 ); 285 m_screensaver-> setDisplayState ( state != 0 );
286 } 286 }
287 else if ( msg == "suspend()" ) { 287 else if ( msg == "suspend()" ) {
288 emit power(); 288 emit power();
289 } 289 }
290} 290}
291 291
292void DesktopApplication::reloadPowerWarnSettings() { 292void DesktopApplication::reloadPowerWarnSettings() {
293 Config cfg( "apm" ); 293 Config cfg( "apm" );
294 cfg.setGroup( "Warnings" ); 294 cfg.setGroup( "Warnings" );
295 295
296 // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); 296 // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) );
297 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); 297 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
298 m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); 298 m_powerCritical = cfg.readNumEntry( "powervcritical", 5 );
299} 299}
300 300
301 301
302enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 302enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
303 303
304#ifdef Q_WS_QWS 304#ifdef Q_WS_QWS
305bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 305bool DesktopApplication::qwsEventFilter( QWSEvent *e )
306{ 306{
307 qpedesktop->checkMemory(); 307 qpedesktop->checkMemory();
308 308
309 if ( e->type == QWSEvent::Key ) { 309 if ( e->type == QWSEvent::Key ) {
310 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 310 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
311 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 311 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
312 return TRUE; 312 return TRUE;
313 bool press = ke->simpleData.is_press; 313 bool press = ke->simpleData.is_press;
314 bool autoRepeat = ke->simpleData.is_auto_repeat; 314 bool autoRepeat = ke->simpleData.is_auto_repeat;
315 315
316 /* 316 /*
317 app that registers key/message to be sent back to the app, when it doesn't have focus, 317 app that registers key/message to be sent back to the app, when it doesn't have focus,
318 when user presses key, unless keyboard has been requested from app. 318 when user presses key, unless keyboard has been requested from app.
319 will not send multiple repeats if user holds key 319 will not send multiple repeats if user holds key
320 i.e. one shot 320 i.e. one shot
321 */ 321 */
322 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { 322 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) {
323// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); 323// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode);
324 KeyRegisterList::Iterator it; 324 KeyRegisterList::Iterator it;
325 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 325 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
326 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { 326 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) {
327 if ( press ) 327 if ( press )
328 qDebug( "press" ); 328 qDebug( "press" );
329 else 329 else
330 qDebug( "release" ); 330 qDebug( "release" );
331 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); 331 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
332 } 332 }
333 } 333 }
334 } 334 }
335 335
336 if ( !keyboardGrabbed() ) { 336 if ( !keyboardGrabbed() ) {
337 if ( ke->simpleData.keycode == Key_F9 ) { 337 if ( ke->simpleData.keycode == Key_F9 ) {
338 if ( press ) 338 if ( press )
339 emit datebook(); 339 emit datebook();
340 return TRUE; 340 return TRUE;
341 } 341 }
342 if ( ke->simpleData.keycode == Key_F10 ) { 342 if ( ke->simpleData.keycode == Key_F10 ) {
343 if ( !press && cardSendTimer ) { 343 if ( !press && cardSendTimer ) {
344 emit contacts(); 344 emit contacts();
345 delete cardSendTimer; 345 delete cardSendTimer;
346 } 346 }
347 else if ( press ) { 347 else if ( press ) {
348 cardSendTimer = new QTimer(); 348 cardSendTimer = new QTimer();
349 cardSendTimer->start( 2000, TRUE ); 349 cardSendTimer->start( 2000, TRUE );
350 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 350 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
351 } 351 }
352 return TRUE; 352 return TRUE;
353 } 353 }
354 354
355// if ( ke->simpleData.keycode == Key_F11 ) { 355// if ( ke->simpleData.keycode == Key_F11 ) {
356// if ( press ) emit menu(); 356// if ( press ) emit menu();
357// return TRUE; 357// return TRUE;
358// } 358// }
359 359
360 if ( ke->simpleData.keycode == Key_F12 ) { 360 if ( ke->simpleData.keycode == Key_F12 ) {
361 while ( activePopupWidget() ) 361 while ( activePopupWidget() )
362 activePopupWidget() ->close(); 362 activePopupWidget() ->close();
363 if ( press ) 363 if ( press )
364 emit launch(); 364 emit launch();
365 return TRUE; 365 return TRUE;
366 } 366 }
367 if ( ke->simpleData.keycode == Key_F13 ) { 367 if ( ke->simpleData.keycode == Key_F13 ) {
368 if ( press ) 368 if ( press )
369 emit email(); 369 emit email();
370 return TRUE; 370 return TRUE;
371 } 371 }
372 } 372 }
373 373
374 if ( ke->simpleData.keycode == Key_F34 ) { 374 if ( ke->simpleData.keycode == Key_F34 ) {
375 if ( press ) 375 if ( press )
376 emit power(); 376 emit power();
377 return TRUE; 377 return TRUE;
378 } 378 }
379 // This was used for the iPAQ PowerButton 379 // This was used for the iPAQ PowerButton
380 // See main.cpp for new KeyboardFilter 380 // See main.cpp for new KeyboardFilter
381 // 381 //
382 // if ( ke->simpleData.keycode == Key_SysReq ) { 382 // if ( ke->simpleData.keycode == Key_SysReq ) {
383 // if ( press ) emit power(); 383 // if ( press ) emit power();
384 // return TRUE; 384 // return TRUE;
385 // } 385 // }
386 if ( ke->simpleData.keycode == Key_F35 ) { 386 if ( ke->simpleData.keycode == Key_F35 ) {
387 if ( press ) 387 if ( press )
388 emit backlight(); 388 emit backlight();
389 return TRUE; 389 return TRUE;
390 } 390 }
391 if ( ke->simpleData.keycode == Key_F32 ) { 391 if ( ke->simpleData.keycode == Key_F32 ) {
392 if ( press ) 392 if ( press )
393 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 393 QCopEnvelope e( "QPE/Desktop", "startSync()" );
394 return TRUE; 394 return TRUE;
395 } 395 }
396 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 396 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
397 if ( press ) 397 if ( press )
398 emit symbol(); 398 emit symbol();
399 return TRUE; 399 return TRUE;
400 } 400 }
401 if ( ke->simpleData.keycode == Key_NumLock ) { 401 if ( ke->simpleData.keycode == Key_NumLock ) {
402 if ( press ) 402 if ( press )
403 emit numLockStateToggle(); 403 emit numLockStateToggle();
404 } 404 }
405 if ( ke->simpleData.keycode == Key_CapsLock ) { 405 if ( ke->simpleData.keycode == Key_CapsLock ) {
406 if ( press ) 406 if ( press )
407 emit capsLockStateToggle(); 407 emit capsLockStateToggle();
408 } 408 }
409 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) 409 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) )
410 qpedesktop->keyClick(); 410 qpedesktop->keyClick();
411 } 411 }
412 else { 412 else {
413 if ( e->type == QWSEvent::Mouse ) { 413 if ( e->type == QWSEvent::Mouse ) {
414 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 414 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
415 static bool up = TRUE; 415 static bool up = TRUE;
416 if ( me->simpleData.state & LeftButton ) { 416 if ( me->simpleData.state & LeftButton ) {
417 if ( up ) { 417 if ( up ) {
418 up = FALSE; 418 up = FALSE;
419 qpedesktop->screenClick(); 419 qpedesktop->screenClick();
420 } 420 }
421 } 421 }
422 else { 422 else {
423 up = TRUE; 423 up = TRUE;
424 } 424 }
425 } 425 }
426 } 426 }
427 427
428 return QPEApplication::qwsEventFilter( e ); 428 return QPEApplication::qwsEventFilter( e );
429} 429}
430#endif 430#endif
431 431
432 432
433void DesktopApplication::sendCard() 433void DesktopApplication::sendCard()
434{ 434{
435 delete cardSendTimer; 435 delete cardSendTimer;
436 cardSendTimer = 0; 436 cardSendTimer = 0;
437 QString card = getenv( "HOME" ); 437 QString card = getenv( "HOME" );
438 card += "/Applications/addressbook/businesscard.vcf"; 438 card += "/Applications/addressbook/businesscard.vcf";
439 439
440 if ( QFile::exists( card ) ) { 440 if ( QFile::exists( card ) ) {
441 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); 441 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" );
442 QString mimetype = "text/x-vCard"; 442 QString mimetype = "text/x-vCard";
443 e << tr( "business card" ) << card << mimetype; 443 e << tr( "business card" ) << card << mimetype;
444 } 444 }
445} 445}
446 446
447#if defined(QPE_HAVE_MEMALERTER) 447#if defined(QPE_HAVE_MEMALERTER)
448QPE_MEMALERTER_IMPL 448QPE_MEMALERTER_IMPL
449#endif 449#endif
450 450
451//=========================================================================== 451//===========================================================================
452 452
453Desktop::Desktop() : 453Desktop::Desktop() :
454 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 454 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
455 qcopBridge( 0 ), 455 qcopBridge( 0 ),
456 transferServer( 0 ), 456 transferServer( 0 ),
457 packageSlave( 0 ) 457 packageSlave( 0 )
458{ 458{
459 qpedesktop = this; 459 qpedesktop = this;
460 460
461 // bg = new Info( this ); 461 // bg = new Info( this );
462 tb = new TaskBar; 462 tb = new TaskBar;
463 463
464 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 464 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
465 465
466 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 466 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
467 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 467 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
468 468
469 int displayw = qApp->desktop() ->width(); 469 int displayw = qApp->desktop() ->width();
470 int displayh = qApp->desktop() ->height(); 470 int displayh = qApp->desktop() ->height();
471 471
472 472
473 QSize sz = tb->sizeHint(); 473 QSize sz = tb->sizeHint();
474 474
475 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 475 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
476 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 476 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
477 477
478 tb->show(); 478 tb->show();
479 launcher->showMaximized(); 479 launcher->showMaximized();
480 launcher->show(); 480 launcher->show();
481 launcher->raise(); 481 launcher->raise();
482#if defined(QPE_HAVE_MEMALERTER) 482#if defined(QPE_HAVE_MEMALERTER)
483 483
484 initMemalerter(); 484 initMemalerter();
485#endif 485#endif
486 // start services 486 // start services
487 startTransferServer(); 487 startTransferServer();
488 ( void ) new IrServer( this ); 488 ( void ) new IrServer( this );
489 rereadVolumes(); 489 rereadVolumes();
490 490
491 packageSlave = new PackageSlave( this ); 491 packageSlave = new PackageSlave( this );
492 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 492 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
493 493
494 qApp->installEventFilter( this ); 494 qApp->installEventFilter( this );
495 495
496 qApp-> setMainWidget ( launcher ); 496 qApp-> setMainWidget ( launcher );
497} 497}
498 498
499void Desktop::show() 499void Desktop::show()
500{ 500{
501 login( TRUE ); 501 login( TRUE );
502 QWidget::show(); 502 QWidget::show();
503} 503}
504 504
505Desktop::~Desktop() 505Desktop::~Desktop()
506{ 506{
507 delete launcher; 507 delete launcher;
508 delete tb; 508 delete tb;
509 delete qcopBridge; 509 delete qcopBridge;
510 delete transferServer; 510 delete transferServer;
511} 511}
512 512
513bool Desktop::recoverMemory() 513bool Desktop::recoverMemory()
514{ 514{
515 return tb->recoverMemory(); 515 return tb->recoverMemory();
516} 516}
517 517
518void Desktop::checkMemory() 518void Desktop::checkMemory()
519{ 519{
520#if defined(QPE_HAVE_MEMALERTER) 520#if defined(QPE_HAVE_MEMALERTER)
521 static bool ignoreNormal = FALSE; 521 static bool ignoreNormal = FALSE;
522 static bool existingMessage = FALSE; 522 static bool existingMessage = FALSE;
523 523
524 if ( existingMessage ) 524 if ( existingMessage )
525 return ; // don't show a second message while still on first 525 return ; // don't show a second message while still on first
526 526
527 existingMessage = TRUE; 527 existingMessage = TRUE;
528 switch ( memstate ) { 528 switch ( memstate ) {
529 case Unknown: 529 case Unknown:
530 break; 530 break;
531 case Low: 531 case Low:
532 memstate = Unknown; 532 memstate = Unknown;
533 if ( recoverMemory() ) 533 if ( recoverMemory() )
534 ignoreNormal = TRUE; 534 ignoreNormal = TRUE;
535 else 535 else
536 QMessageBox::warning( 0 , "Memory Status", 536 QMessageBox::warning( 0 , "Memory Status",
537 "The memory smacks of shortage. \n" 537 "The memory smacks of shortage. \n"
538 "Please save data. " ); 538 "Please save data. " );
539 break; 539 break;
540 case Normal: 540 case Normal:
541 memstate = Unknown; 541 memstate = Unknown;
542 if ( ignoreNormal ) 542 if ( ignoreNormal )
543 ignoreNormal = FALSE; 543 ignoreNormal = FALSE;
544// else 544// else
545// QMessageBox::information ( 0 , "Memory Status", 545// QMessageBox::information ( 0 , "Memory Status",
546// "There is enough memory again." ); 546// "There is enough memory again." );
547 break; 547 break;
548 case VeryLow: 548 case VeryLow:
549 memstate = Unknown; 549 memstate = Unknown;
550 QMessageBox::critical( 0 , "Memory Status", 550 QMessageBox::critical( 0 , "Memory Status",
551 "The memory is very low. \n" 551 "The memory is very low. \n"
552 "Please end this application \n" 552 "Please end this application \n"
553 "immediately." ); 553 "immediately." );
554 recoverMemory(); 554 recoverMemory();
555 } 555 }
556 existingMessage = FALSE; 556 existingMessage = FALSE;
557#endif 557#endif
558} 558}
559 559
560static bool isVisibleWindow( int wid ) 560static bool isVisibleWindow( int wid )
561{ 561{
562#ifdef QWS 562#ifdef QWS
563 const QList<QWSWindow> &list = qwsServer->clientWindows(); 563 const QList<QWSWindow> &list = qwsServer->clientWindows();
564 QWSWindow* w; 564 QWSWindow* w;
565 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 565 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
566 if ( w->winId() == wid ) 566 if ( w->winId() == wid )
567 return !w->isFullyObscured(); 567 return !w->isFullyObscured();
568 } 568 }
569#endif 569#endif
570 return FALSE; 570 return FALSE;
571} 571}
572 572
573static bool hasVisibleWindow( const QString& clientname ) 573static bool hasVisibleWindow( const QString& clientname )
574{ 574{
575#ifdef QWS 575#ifdef QWS
576 const QList<QWSWindow> &list = qwsServer->clientWindows(); 576 const QList<QWSWindow> &list = qwsServer->clientWindows();
577 QWSWindow* w; 577 QWSWindow* w;
578 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 578 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
579 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 579 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
580 return TRUE; 580 return TRUE;
581 } 581 }
582#endif 582#endif
583 return FALSE; 583 return FALSE;
584} 584}
585 585
586void Desktop::raiseLauncher() 586void Desktop::raiseLauncher()
587{ 587{
588 Config cfg( "qpe" ); //F12 'Home' 588 Config cfg( "qpe" ); //F12 'Home'
589 cfg.setGroup( "AppsKey" ); 589 cfg.setGroup( "AppsKey" );
590 QString tempItem; 590 QString tempItem;
591 tempItem = cfg.readEntry( "Middle", "Home" ); 591 tempItem = cfg.readEntry( "Middle", "Home" );
592 if ( tempItem == "Home" || tempItem.isEmpty() ) { 592 if ( tempItem == "Home" || tempItem.isEmpty() ) {
593 home ( ); 593 home ( );
594 } 594 }
595 else { 595 else {
596 QCopEnvelope e( "QPE/System", "execute(QString)" ); 596 QCopEnvelope e( "QPE/System", "execute(QString)" );
597 e << tempItem; 597 e << tempItem;
598 } 598 }
599} 599}
600 600
601void Desktop::home ( ) 601void Desktop::home ( )
602{ 602{
603 if ( isVisibleWindow( launcher->winId() ) ) 603 if ( isVisibleWindow( launcher->winId() ) )
604 launcher->nextView(); 604 launcher->nextView();
605 else 605 else
606 launcher->raise(); 606 launcher->raise();
607} 607}
608 608
609void Desktop::executeOrModify( const QString& appLnkFile ) 609void Desktop::executeOrModify( const QString& appLnkFile )
610{ 610{
611 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 611 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
612 if ( lnk.isValid() ) { 612 if ( lnk.isValid() ) {
613 QCString app = lnk.exec().utf8(); 613 QCString app = lnk.exec().utf8();
614 Global::terminateBuiltin( "calibrate" ); 614 Global::terminateBuiltin( "calibrate" );
615 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 615 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
616 // MRUList::addTask( &lnk ); 616 // MRUList::addTask( &lnk );
617 if ( hasVisibleWindow( app ) ) 617 if ( hasVisibleWindow( app ) )
618 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 618 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
619 else 619 else
620 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 620 QCopChannel::send( "QPE/Application/" + app, "raise()" );
621 } 621 }
622 else { 622 else {
623 lnk.execute(); 623 lnk.execute();
624 } 624 }
625 } 625 }
626} 626}
627 627
628void Desktop::raiseDatebook() 628void Desktop::raiseDatebook()
629{ 629{
630 Config cfg( "qpe" ); //F9 'Activity' 630 Config cfg( "qpe" ); //F9 'Activity'
631 cfg.setGroup( "AppsKey" ); 631 cfg.setGroup( "AppsKey" );
632 QString tempItem; 632 QString tempItem;
633 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); 633 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
634 if ( tempItem == "Calendar" || tempItem.isEmpty() ) { 634 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
635 tempItem = "datebook"; 635 tempItem = "datebook";
636 } 636 }
637 QCopEnvelope e( "QPE/System", "execute(QString)" ); 637 QCopEnvelope e( "QPE/System", "execute(QString)" );
638 e << tempItem; 638 e << tempItem;
639} 639}
640 640
641void Desktop::raiseContacts() 641void Desktop::raiseContacts()
642{ 642{
643 Config cfg( "qpe" ); //F10, 'Contacts' 643 Config cfg( "qpe" ); //F10, 'Contacts'
644 cfg.setGroup( "AppsKey" ); 644 cfg.setGroup( "AppsKey" );
645 QString tempItem; 645 QString tempItem;
646 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 646 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
647 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 647 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
648 tempItem = "addressbook"; 648 tempItem = "addressbook";
649 } 649 }
650 QCopEnvelope e( "QPE/System", "execute(QString)" ); 650 QCopEnvelope e( "QPE/System", "execute(QString)" );
651 e << tempItem; 651 e << tempItem;
652} 652}
653 653
654void Desktop::raiseMenu() 654void Desktop::raiseMenu()
655{ 655{
656 Config cfg( "qpe" ); //F11, 'Menu 656 Config cfg( "qpe" ); //F11, 'Menu
657 cfg.setGroup( "AppsKey" ); 657 cfg.setGroup( "AppsKey" );
658 QString tempItem; 658 QString tempItem;
659 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 659 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
660 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 660 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
661 Global::terminateBuiltin( "calibrate" ); 661 Global::terminateBuiltin( "calibrate" );
662 tb->startMenu() ->launch(); 662 tb->startMenu() ->launch();
663 } 663 }
664 else { 664 else {
665 QCopEnvelope e( "QPE/System", "execute(QString)" ); 665 QCopEnvelope e( "QPE/System", "execute(QString)" );
666 e << tempItem; 666 e << tempItem;
667 } 667 }
668} 668}
669 669
670void Desktop::raiseEmail() 670void Desktop::raiseEmail()
671{ 671{
672 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 672 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
673 cfg.setGroup( "AppsKey" ); 673 cfg.setGroup( "AppsKey" );
674 QString tempItem; 674 QString tempItem;
675 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 675 tempItem = cfg.readEntry( "RightEnd", "Mail" );
676 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 676 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
677 tempItem = "mail"; 677 tempItem = "mail";
678 } 678 }
679 QCopEnvelope e( "QPE/System", "execute(QString)" ); 679 QCopEnvelope e( "QPE/System", "execute(QString)" );
680 e << tempItem; 680 e << tempItem;
681} 681}
682 682
683// autoStarts apps on resume and start 683// autoStarts apps on resume and start
684void Desktop::execAutoStart() 684void Desktop::execAutoStart()
685{ 685{
686 QString appName; 686 QString appName;
687 int delay; 687 int delay;
688 QDateTime now = QDateTime::currentDateTime(); 688 QDateTime now = QDateTime::currentDateTime();
689 Config cfg( "autostart" ); 689 Config cfg( "autostart" );
690 cfg.setGroup( "AutoStart" ); 690 cfg.setGroup( "AutoStart" );
691 appName = cfg.readEntry( "Apps", "" ); 691 appName = cfg.readEntry( "Apps", "" );
692 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 692 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
693 // If the time between suspend and resume was longer then the 693 // If the time between suspend and resume was longer then the
694 // value saved as delay, start the app 694 // value saved as delay, start the app
695 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 695 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
696 QCopEnvelope e( "QPE/System", "execute(QString)" ); 696 QCopEnvelope e( "QPE/System", "execute(QString)" );
697 e << QString( appName ); 697 e << QString( appName );
698 } 698 }
699} 699}
700 700
701#if defined(QPE_HAVE_TOGGLELIGHT) 701#if defined(QPE_HAVE_TOGGLELIGHT)
702#include <qpe/config.h> 702#include <qpe/config.h>
703 703
704#include <sys/ioctl.h> 704#include <sys/ioctl.h>
705#include <sys/types.h> 705#include <sys/types.h>
706#include <fcntl.h> 706#include <fcntl.h>
707#include <unistd.h> 707#include <unistd.h>
708#include <errno.h> 708#include <errno.h>
709#include <linux/ioctl.h> 709#include <linux/ioctl.h>
710#include <time.h> 710#include <time.h>
711#endif 711#endif
712 712
713 713
714void Desktop::togglePower() 714void Desktop::togglePower()
715{ 715{
716 static bool excllock = false; 716 static bool excllock = false;
717 717
718 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); 718 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
719 719
720 if ( excllock ) 720 if ( excllock )
721 return; 721 return;
722 722
723 excllock = true; 723 excllock = true;
724 724
725 bool wasloggedin = loggedin; 725 bool wasloggedin = loggedin;
726 loggedin = 0; 726 loggedin = 0;
727 suspendTime = QDateTime::currentDateTime(); 727 suspendTime = QDateTime::currentDateTime();
728 728
729#ifdef QWS 729#ifdef QWS
730 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 730 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
731 // Should use a big black window instead. 731 // Should use a big black window instead.
732 // But this would not show up fast enough 732 // But this would not show up fast enough
733 QGfx *g = qt_screen-> screenGfx ( ); 733 QGfx *g = qt_screen-> screenGfx ( );
734 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 734 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
735 delete g; 735 delete g;
736 } 736 }
737#endif 737#endif
738 738
739 ODevice::inst ( )-> suspend ( ); 739 ODevice::inst ( )-> suspend ( );
740 740
741 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 741 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
742 QWSServer::screenSaverActivate ( false ); 742 QWSServer::screenSaverActivate ( false );
743 743
744 { 744 {
745 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 745 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
746 } 746 }
747 747
748 if ( wasloggedin ) 748 if ( wasloggedin )
749 login ( true ); 749 login ( true );
750 750
751 execAutoStart(); 751 execAutoStart();
752 //qcopBridge->closeOpenConnections(); 752 //qcopBridge->closeOpenConnections();
753 753
754 excllock = false; 754 excllock = false;
755} 755}
756 756
757void Desktop::toggleLight() 757void Desktop::toggleLight()
758{ 758{
759 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 759 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
760 e << -2; // toggle 760 e << -2; // toggle
761} 761}
762 762
763void Desktop::toggleSymbolInput() 763void Desktop::toggleSymbolInput()
764{ 764{
765 tb->toggleSymbolInput(); 765 tb->toggleSymbolInput();
766} 766}
767 767
768void Desktop::toggleNumLockState() 768void Desktop::toggleNumLockState()
769{ 769{
770 tb->toggleNumLockState(); 770 tb->toggleNumLockState();
771} 771}
772 772
773void Desktop::toggleCapsLockState() 773void Desktop::toggleCapsLockState()
774{ 774{
775 tb->toggleCapsLockState(); 775 tb->toggleCapsLockState();
776} 776}
777 777
778void Desktop::styleChange( QStyle &s ) 778void Desktop::styleChange( QStyle &s )
779{ 779{
780 QWidget::styleChange( s ); 780 QWidget::styleChange( s );
781 int displayw = qApp->desktop() ->width(); 781 int displayw = qApp->desktop() ->width();
782 int displayh = qApp->desktop() ->height(); 782 int displayh = qApp->desktop() ->height();
783 783
784 QSize sz = tb->sizeHint(); 784 QSize sz = tb->sizeHint();
785 785
786 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 786 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
787} 787}
788 788
789void DesktopApplication::shutdown() 789void DesktopApplication::shutdown()
790{ 790{
791 if ( type() != GuiServer ) 791 if ( type() != GuiServer )
792 return ; 792 return ;
793 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 793 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
794 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 794 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
795 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 795 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
796 sd->showMaximized(); 796 sd->showMaximized();
797} 797}
798 798
799void DesktopApplication::shutdown( ShutdownImpl::Type t ) 799void DesktopApplication::shutdown( ShutdownImpl::Type t )
800{ 800{
801 switch ( t ) { 801 switch ( t ) {
802 case ShutdownImpl::ShutdownSystem: 802 case ShutdownImpl::ShutdownSystem:
803 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); 803 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 );
804 break; 804 break;
805 case ShutdownImpl::RebootSystem: 805 case ShutdownImpl::RebootSystem:
806 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); 806 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 );
807 break; 807 break;
808 case ShutdownImpl::RestartDesktop: 808 case ShutdownImpl::RestartDesktop:
809 restart(); 809 restart();
810 break; 810 break;
811 case ShutdownImpl::TerminateDesktop: 811 case ShutdownImpl::TerminateDesktop:
812 prepareForTermination( FALSE ); 812 prepareForTermination( FALSE );
813 813
814 // This is a workaround for a Qt bug 814 // This is a workaround for a Qt bug
815 // clipboard applet has to stop its poll timer, or Qt/E 815 // clipboard applet has to stop its poll timer, or Qt/E
816 // will hang on quit() right before it emits aboutToQuit() 816 // will hang on quit() right before it emits aboutToQuit()
817 emit aboutToQuit ( ); 817 emit aboutToQuit ( );
818 818
819 quit(); 819 quit();
820 break; 820 break;
821 } 821 }
822} 822}
823 823
824void DesktopApplication::restart() 824void DesktopApplication::restart()
825{ 825{
826 prepareForTermination( TRUE ); 826 prepareForTermination( TRUE );
827 827
828#ifdef Q_WS_QWS 828#ifdef Q_WS_QWS
829 829
830 for ( int fd = 3; fd < 100; fd++ ) 830 for ( int fd = 3; fd < 100; fd++ )
831 close( fd ); 831 close( fd );
832#if defined(QT_DEMO_SINGLE_FLOPPY) 832#if defined(QT_DEMO_SINGLE_FLOPPY)
833 833
834 execl( "/sbin/init", "qpe", 0 ); 834 execl( "/sbin/init", "qpe", 0 );
835#elif defined(QT_QWS_CASSIOPEIA) 835#elif defined(QT_QWS_CASSIOPEIA)
836 836
837 execl( "/bin/sh", "sh", 0 ); 837 execl( "/bin/sh", "sh", 0 );
838#else 838#else
839 839
840 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 840 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
841#endif 841#endif
842 842
843 exit( 1 ); 843 exit( 1 );
844#endif 844#endif
845} 845}
846 846
847void Desktop::startTransferServer() 847void Desktop::startTransferServer()
848{ 848{
849 // start qcop bridge server 849 // start qcop bridge server
850 qcopBridge = new QCopBridge( 4243 ); 850 qcopBridge = new QCopBridge( 4243 );
851 if ( !qcopBridge->ok() ) { 851 if ( !qcopBridge->ok() ) {
852 delete qcopBridge; 852 delete qcopBridge;
853 qcopBridge = 0; 853 qcopBridge = 0;
854 } 854 }
855 // start transfer server 855 // start transfer server
856 transferServer = new TransferServer( 4242 ); 856 transferServer = new TransferServer( 4242 );
857 if ( !transferServer->ok() ) { 857 if ( !transferServer->ok() ) {
858 delete transferServer; 858 delete transferServer;
859 transferServer = 0; 859 transferServer = 0;
860 } 860 }
861 if ( !transferServer || !qcopBridge ) 861 if ( !transferServer || !qcopBridge )
862 startTimer( 2000 ); 862 startTimer( 2000 );
863} 863}
864 864
865void Desktop::timerEvent( QTimerEvent *e ) 865void Desktop::timerEvent( QTimerEvent *e )
866{ 866{
867 killTimer( e->timerId() ); 867 killTimer( e->timerId() );
868 startTransferServer(); 868 startTransferServer();
869} 869}
870 870
871void Desktop::terminateServers() 871void Desktop::terminateServers()
872{ 872{
873 delete transferServer; 873 delete transferServer;
874 delete qcopBridge; 874 delete qcopBridge;
875 transferServer = 0; 875 transferServer = 0;
876 qcopBridge = 0; 876 qcopBridge = 0;
877} 877}
878 878
879void Desktop::rereadVolumes() 879void Desktop::rereadVolumes()
880{ 880{
881 Config cfg( "qpe" ); 881 Config cfg( "qpe" );
882 cfg.setGroup( "Volume" ); 882 cfg.setGroup( "Volume" );
883 touchclick = cfg.readBoolEntry( "TouchSound" ); 883 touchclick = cfg.readBoolEntry( "TouchSound" );
884 keyclick = cfg.readBoolEntry( "KeySound" ); 884 keyclick = cfg.readBoolEntry( "KeySound" );
885 alarmsound = cfg.readBoolEntry( "AlarmSound" ); 885 alarmsound = cfg.readBoolEntry( "AlarmSound" );
886} 886}
887 887
888void Desktop::keyClick() 888void Desktop::keyClick()
889{ 889{
890 if ( keyclick ) 890 if ( keyclick )
891 ODevice::inst ( ) -> keySound ( ); 891 ODevice::inst ( ) -> keySound ( );
892} 892}
893 893
894void Desktop::screenClick() 894void Desktop::screenClick()
895{ 895{
896 if ( touchclick ) 896 if ( touchclick )
897 ODevice::inst ( ) -> touchSound ( ); 897 ODevice::inst ( ) -> touchSound ( );
898} 898}
899 899
900void Desktop::soundAlarm() 900void Desktop::soundAlarm()
901{ 901{
902 if ( qpedesktop-> alarmsound ) 902 if ( qpedesktop-> alarmsound )
903 ODevice::inst ( ) -> alarmSound ( ); 903 ODevice::inst ( ) -> alarmSound ( );
904} 904}
905 905
906bool Desktop::eventFilter( QObject *, QEvent *ev ) 906bool Desktop::eventFilter( QObject *, QEvent *ev )
907{ 907{
908 if ( ev->type() == QEvent::KeyPress ) { 908 if ( ev->type() == QEvent::KeyPress ) {
909 QKeyEvent *ke = (QKeyEvent *)ev; 909 QKeyEvent *ke = (QKeyEvent *)ev;
910 if ( ke->key() == Qt::Key_F11 ) { // menu key 910 if ( ke->key() == Qt::Key_F11 ) { // menu key
911 QWidget *active = qApp->activeWindow(); 911 QWidget *active = qApp->activeWindow();
912 if ( active && active->isPopup() ) { 912 if ( active && active->isPopup() ) {
913 active->close(); 913 active->close();
914 } 914 }
915 raiseMenu(); 915 raiseMenu();
916 return TRUE; 916 return TRUE;
917 } 917 }
918 } 918 }
919 return FALSE; 919 return FALSE;
920} 920}
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index b517c7d..8b91f5d 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,182 +1,182 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "taskbar.h" 22#include "taskbar.h"
23#include "stabmon.h" 23#include "stabmon.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/network.h> 26#include <qpe/network.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ )
29#include <qpe/custom.h> 29#include <qpe/custom.h>
30#endif 30#endif
31 31
32#include <opie/odevice.h> 32#include <opie/odevice.h>
33 33
34#include <qmessagebox.h> 34#include <qmessagebox.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#include <qpe/alarmserver.h> 39#include <qpe/alarmserver.h>
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <signal.h> 43#include <signal.h>
44#include <unistd.h> 44#include <unistd.h>
45 45
46#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 46#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
47#include "../calibrate/calibrate.h" 47#include "../calibrate/calibrate.h"
48#endif 48#endif
49 49
50using namespace Opie; 50using namespace Opie;
51 51
52void initEnvironment() 52void initEnvironment()
53{ 53{
54 Config config("locale"); 54 Config config("locale");
55 config.setGroup( "Location" ); 55 config.setGroup( "Location" );
56 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 56 QString tz = config.readEntry( "Timezone", getenv("TZ") );
57 57
58 // if not timezone set, pick New York 58 // if not timezone set, pick New York
59 if (tz.isNull()) 59 if (tz.isNull())
60 tz = "America/New_York"; 60 tz = "America/New_York";
61 61
62 setenv( "TZ", tz, 1 ); 62 setenv( "TZ", tz, 1 );
63 config.writeEntry( "Timezone", tz); 63 config.writeEntry( "Timezone", tz);
64 64
65 config.setGroup( "Language" ); 65 config.setGroup( "Language" );
66 QString lang = config.readEntry( "Language", getenv("LANG") ); 66 QString lang = config.readEntry( "Language", getenv("LANG") );
67 if ( !lang.isNull() ) 67 if ( !lang.isNull() )
68 setenv( "LANG", lang, 1 ); 68 setenv( "LANG", lang, 1 );
69} 69}
70 70
71 71
72int initApplication( int argc, char ** argv ) 72int initApplication( int argc, char ** argv )
73{ 73{
74 initEnvironment(); 74 initEnvironment();
75 75
76#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 76#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
77 setenv( "QWS_SIZE", "240x320", 0 ); 77 setenv( "QWS_SIZE", "240x320", 0 );
78#endif 78#endif
79 79
80 //Don't flicker at startup: 80 //Don't flicker at startup:
81 QWSServer::setDesktopBackground( QImage() ); 81 QWSServer::setDesktopBackground( QImage() );
82 DesktopApplication a( argc, argv, QApplication::GuiServer ); 82 DesktopApplication a( argc, argv, QApplication::GuiServer );
83 83
84 ODevice::inst ( )-> setSoftSuspend ( true ); 84 ODevice::inst ( )-> setSoftSuspend ( true );
85 85
86 { // init backlight 86 { // init backlight
87 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 87 QCopEnvelope e("QPE/System", "setBacklight(int)" );
88 e << -3; // Forced on 88 e << -3; // Forced on
89 } 89 }
90 90
91 AlarmServer::initialize(); 91 AlarmServer::initialize();
92 92
93 Desktop *d = new Desktop(); 93 Desktop *d = new Desktop();
94 94
95 QObject::connect( &a, SIGNAL(menu()), d, SLOT(raiseMenu()) ); 95 QObject::connect( &a, SIGNAL(menu()), d, SLOT(raiseMenu()) );
96 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 96 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
97 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 97 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
98 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 98 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
99 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 99 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
100 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 100 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
101 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 101 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
102 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 102 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
103 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 103 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
104 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 104 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
105 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 105 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
106 106
107 (void)new SysFileMonitor(d); 107 (void)new SysFileMonitor(d);
108 Network::createServer(d); 108 Network::createServer(d);
109 109
110#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 110#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
111 if ( !QFile::exists( "/etc/pointercal" ) ) { 111 if ( !QFile::exists( "/etc/pointercal" ) ) {
112 // Make sure calibration widget starts on top. 112 // Make sure calibration widget starts on top.
113 Calibrate *cal = new Calibrate; 113 Calibrate *cal = new Calibrate;
114 cal->exec(); 114 cal->exec();
115 delete cal; 115 delete cal;
116 } 116 }
117#endif 117#endif
118 118
119 d->show(); 119 d->show();
120 120
121 if ( QDate::currentDate ( ). year ( ) < 2000 ) { 121 if ( QDate::currentDate ( ). year ( ) < 2000 ) {
122 if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 122 if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
123 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); 123 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
124 e << QString ( ); 124 e << QString ( );
125 } 125 }
126 } 126 }
127 127
128 int rv = a.exec(); 128 int rv = a.exec();
129 129
130 delete d; 130 delete d;
131 131
132 ODevice::inst ( )-> setSoftSuspend ( false ); 132 ODevice::inst ( )-> setSoftSuspend ( false );
133 133
134 return rv; 134 return rv;
135} 135}
136 136
137static const char *pidfile_path = "/var/run/opie.pid"; 137static const char *pidfile_path = "/var/run/opie.pid";
138 138
139void create_pidfile ( ) 139void create_pidfile ( )
140{ 140{
141 FILE *f; 141 FILE *f;
142 142
143 if (( f = ::fopen ( pidfile_path, "w" ))) { 143 if (( f = ::fopen ( pidfile_path, "w" ))) {
144 ::fprintf ( f, "%d", getpid ( )); 144 ::fprintf ( f, "%d", getpid ( ));
145 ::fclose ( f ); 145 ::fclose ( f );
146 } 146 }
147} 147}
148 148
149void remove_pidfile ( ) 149void remove_pidfile ( )
150{ 150{
151 ::unlink ( pidfile_path ); 151 ::unlink ( pidfile_path );
152} 152}
153 153
154void handle_sigterm ( int /* sig */ ) 154void handle_sigterm ( int /* sig */ )
155{ 155{
156 if ( qApp ) 156 if ( qApp )
157 qApp-> quit ( ); 157 qApp-> quit ( );
158} 158}
159 159
160int main( int argc, char ** argv ) 160int main( int argc, char ** argv )
161{ 161{
162 ::signal ( SIGCHLD, SIG_IGN ); 162 ::signal ( SIGCHLD, SIG_IGN );
163 163
164 ::signal ( SIGTERM, handle_sigterm ); 164 ::signal ( SIGTERM, handle_sigterm );
165 ::signal ( SIGINT, handle_sigterm ); 165 ::signal ( SIGINT, handle_sigterm );
166 166
167 ::setsid ( ); 167 ::setsid ( );
168 ::setpgid ( 0, 0 ); 168 ::setpgid ( 0, 0 );
169 169
170 ::atexit ( remove_pidfile ); 170 ::atexit ( remove_pidfile );
171 create_pidfile ( ); 171 create_pidfile ( );
172 172
173 int retVal = initApplication ( argc, argv ); 173 int retVal = initApplication ( argc, argv );
174 174
175 // Kill them. Kill them all. 175 // Kill them. Kill them all.
176 ::kill ( 0, SIGTERM ); 176 ::kill ( 0, SIGTERM );
177 ::sleep ( 1 ); 177 ::sleep ( 1 );
178 ::kill ( 0, SIGKILL ); 178 ::kill ( 0, SIGKILL );
179 179
180 return retVal; 180 return retVal;
181} 181}
182 182
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp
index 9292bb8..a202b7b 100644
--- a/core/launcher/shutdownimpl.cpp
+++ b/core/launcher/shutdownimpl.cpp
@@ -1,179 +1,179 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "shutdownimpl.h" 21#include "shutdownimpl.h"
22 22
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25 25
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qprogressbar.h> 27#include <qprogressbar.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qbuttongroup.h> 29#include <qbuttongroup.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qpalette.h> 32#include <qpalette.h>
33 33
34 34
35static void changeButtonColor ( QPushButton *btn, const QColor &col ) 35static void changeButtonColor ( QPushButton *btn, const QColor &col )
36{ 36{
37 QPalette pal = btn-> palette ( ); 37 QPalette pal = btn-> palette ( );
38 38
39 pal. setColor ( QPalette::Active, QColorGroup::Button, col ); 39 pal. setColor ( QPalette::Active, QColorGroup::Button, col );
40 pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); 40 pal. setColor ( QPalette::Disabled, QColorGroup::Button, col );
41 pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); 41 pal. setColor ( QPalette::Inactive, QColorGroup::Button, col );
42 42
43 btn-> setPalette ( pal ); 43 btn-> setPalette ( pal );
44} 44}
45 45
46 46
47ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) 47ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl )
48 : QWidget ( parent, name, fl ) 48 : QWidget ( parent, name, fl )
49{ 49{
50 setCaption ( tr( "Shut down..." ) ); 50 setCaption ( tr( "Shut down..." ) );
51 51
52 QVBoxLayout *vbox = new QVBoxLayout ( this ); 52 QVBoxLayout *vbox = new QVBoxLayout ( this );
53 vbox-> setSpacing ( 3 ); 53 vbox-> setSpacing ( 3 );
54 vbox-> setMargin ( 6 ); 54 vbox-> setMargin ( 6 );
55 55
56 QButtonGroup *btngrp = new QButtonGroup ( this ); 56 QButtonGroup *btngrp = new QButtonGroup ( this );
57 57
58 btngrp-> setTitle ( tr( "Terminate" ) ); 58 btngrp-> setTitle ( tr( "Terminate" ) );
59 btngrp-> setColumnLayout ( 0, Qt::Vertical ); 59 btngrp-> setColumnLayout ( 0, Qt::Vertical );
60 btngrp-> layout ( ) -> setSpacing ( 0 ); 60 btngrp-> layout ( ) -> setSpacing ( 0 );
61 btngrp-> layout ( ) -> setMargin ( 0 ); 61 btngrp-> layout ( ) -> setMargin ( 0 );
62 62
63 QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) ); 63 QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) );
64 grid-> setAlignment ( Qt::AlignTop ); 64 grid-> setAlignment ( Qt::AlignTop );
65 grid-> setSpacing ( 3 ); 65 grid-> setSpacing ( 3 );
66 grid-> setMargin ( 7 ); 66 grid-> setMargin ( 7 );
67 67
68 QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); 68 QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" );
69 changeButtonColor ( quit, QColor ( 236, 236, 179 ) ); 69 changeButtonColor ( quit, QColor ( 236, 236, 179 ) );
70 btngrp-> insert ( quit, 4 ); 70 btngrp-> insert ( quit, 4 );
71 grid-> addWidget ( quit, 1, 1 ); 71 grid-> addWidget ( quit, 1, 1 );
72 72
73 QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); 73 QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" );
74 changeButtonColor ( reboot, QColor( 236, 183, 181 ) ); 74 changeButtonColor ( reboot, QColor( 236, 183, 181 ) );
75 btngrp-> insert ( reboot, 2 ); 75 btngrp-> insert ( reboot, 2 );
76 grid-> addWidget( reboot, 1, 0 ); 76 grid-> addWidget( reboot, 1, 0 );
77 77
78 QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); 78 QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" );
79 changeButtonColor ( restart, QColor( 236, 236, 179 ) ); 79 changeButtonColor ( restart, QColor( 236, 236, 179 ) );
80 btngrp-> insert ( restart, 3 ); 80 btngrp-> insert ( restart, 3 );
81 grid-> addWidget ( restart, 0, 1 ); 81 grid-> addWidget ( restart, 0, 1 );
82 82
83 QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); 83 QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" );
84 changeButtonColor ( shutdown, QColor( 236, 183, 181 ) ); 84 changeButtonColor ( shutdown, QColor( 236, 183, 181 ) );
85 btngrp-> insert ( shutdown, 1 ); 85 btngrp-> insert ( shutdown, 1 );
86 grid-> addWidget ( shutdown, 0, 0 ); 86 grid-> addWidget ( shutdown, 0, 0 );
87 87
88 vbox-> addWidget ( btngrp ); 88 vbox-> addWidget ( btngrp );
89 89
90 m_info = new QLabel ( this, "info" ); 90 m_info = new QLabel ( this, "info" );
91 m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) ); 91 m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) );
92 vbox-> addWidget ( m_info ); 92 vbox-> addWidget ( m_info );
93 93
94 m_progress = new QProgressBar ( this, "progressBar" ); 94 m_progress = new QProgressBar ( this, "progressBar" );
95 m_progress-> setFrameShape ( QProgressBar::Panel ); 95 m_progress-> setFrameShape ( QProgressBar::Panel );
96 m_progress-> setFrameShadow ( QProgressBar::Sunken ); 96 m_progress-> setFrameShadow ( QProgressBar::Sunken );
97 m_progress-> setTotalSteps ( 20 ); 97 m_progress-> setTotalSteps ( 20 );
98 m_progress-> setIndicatorFollowsStyle ( false ); 98 m_progress-> setIndicatorFollowsStyle ( false );
99 vbox-> addWidget ( m_progress ); 99 vbox-> addWidget ( m_progress );
100 100
101 vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 101 vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
102 102
103 QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); 103 QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" );
104 changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); 104 changeButtonColor ( cancel, QColor( 181, 222, 178 ) );
105 cancel-> setDefault ( true ); 105 cancel-> setDefault ( true );
106 cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); 106 cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) );
107 vbox-> addWidget ( cancel ); 107 vbox-> addWidget ( cancel );
108 108
109 m_timer = new QTimer ( this ); 109 m_timer = new QTimer ( this );
110 connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) ); 110 connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) );
111 111
112 connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) ); 112 connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) );
113 connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) ); 113 connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) );
114 114
115 m_progress-> hide ( ); 115 m_progress-> hide ( );
116 Global::hideInputMethod ( ); 116 Global::hideInputMethod ( );
117 117
118#ifdef QT_QWS_CUSTOM 118#ifdef QT_QWS_SHARP
119 119
120 shutdown-> hide ( ); 120 shutdown-> hide ( );
121#endif 121#endif
122} 122}
123 123
124void ShutdownImpl::buttonClicked ( int b ) 124void ShutdownImpl::buttonClicked ( int b )
125{ 125{
126 m_counter = 0; 126 m_counter = 0;
127 127
128 switch ( b ) { 128 switch ( b ) {
129 case 1: 129 case 1:
130 m_operation = ShutdownSystem; 130 m_operation = ShutdownSystem;
131 break; 131 break;
132 case 2: 132 case 2:
133 m_operation = RebootSystem; 133 m_operation = RebootSystem;
134 break; 134 break;
135 case 3: 135 case 3:
136 m_operation = RestartDesktop; 136 m_operation = RestartDesktop;
137 break; 137 break;
138 case 4: 138 case 4:
139 m_operation = TerminateDesktop; 139 m_operation = TerminateDesktop;
140 break; 140 break;
141 } 141 }
142 m_info-> hide ( ); 142 m_info-> hide ( );
143 m_progress-> show ( ); 143 m_progress-> show ( );
144 m_timer-> start ( 300 ); 144 m_timer-> start ( 300 );
145 timeout ( ); 145 timeout ( );
146} 146}
147 147
148void ShutdownImpl::cancelClicked ( ) 148void ShutdownImpl::cancelClicked ( )
149{ 149{
150 m_progress-> hide ( ); 150 m_progress-> hide ( );
151 m_info-> show ( ); 151 m_info-> show ( );
152 if ( m_timer-> isActive ( ) ) 152 if ( m_timer-> isActive ( ) )
153 m_timer-> stop ( ); 153 m_timer-> stop ( );
154 else 154 else
155 close ( ); 155 close ( );
156} 156}
157 157
158void ShutdownImpl::timeout ( ) 158void ShutdownImpl::timeout ( )
159{ 159{
160 if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { 160 if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) {
161 m_progress-> hide ( ); 161 m_progress-> hide ( );
162 m_timer-> stop ( ); 162 m_timer-> stop ( );
163 emit shutdown ( m_operation ); 163 emit shutdown ( m_operation );
164 } 164 }
165 else 165 else
166 m_progress-> setProgress ( m_counter ); 166 m_progress-> setProgress ( m_counter );
167} 167}
168 168
169void ShutdownImpl::hide ( ) 169void ShutdownImpl::hide ( )
170{ 170{
171 if ( isVisible ( )) { 171 if ( isVisible ( )) {
172 // hack - shutdown is a launcher dialog, but treated like a standalone app 172 // hack - shutdown is a launcher dialog, but treated like a standalone app
173 QCopEnvelope e( "QPE/System", "closing(QString)" ); 173 QCopEnvelope e( "QPE/System", "closing(QString)" );
174 e << QString ( "shutdown" ); 174 e << QString ( "shutdown" );
175 175
176 } 176 }
177 QWidget::hide ( ); 177 QWidget::hide ( );
178} 178}
179 179
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 7d1aaf1..1e6b74e 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,338 +1,338 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*********************************************************************/ 19*********************************************************************/
20 20
21#include "startmenu.h" 21#include "startmenu.h"
22#include "inputmethods.h" 22#include "inputmethods.h"
23#include "runningappbar.h" 23#include "runningappbar.h"
24#include "systray.h" 24#include "systray.h"
25#include "calibrate.h" 25#include "calibrate.h"
26#include "wait.h" 26#include "wait.h"
27#include "appicons.h" 27#include "appicons.h"
28 28
29#include "taskbar.h" 29#include "taskbar.h"
30#include "desktop.h" 30#include "desktop.h"
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/global.h> 34#include <qpe/global.h>
35 35
36#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 36#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ )
37#include <qpe/custom.h> 37#include <qpe/custom.h>
38#endif 38#endif
39 39
40#include <opie/odevice.h> 40#include <opie/odevice.h>
41 41
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qtimer.h> 44#include <qtimer.h>
45#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
46#include <qwidgetstack.h> 46#include <qwidgetstack.h>
47 47
48#if defined( Q_WS_QWS ) 48#if defined( Q_WS_QWS )
49#include <qwsdisplay_qws.h> 49#include <qwsdisplay_qws.h>
50#include <qgfx_qws.h> 50#include <qgfx_qws.h>
51#endif 51#endif
52 52
53 53
54using namespace Opie; 54using namespace Opie;
55 55
56#define FACTORY(T) \ 56#define FACTORY(T) \
57 static QWidget *new##T( bool maximized ) { \ 57 static QWidget *new##T( bool maximized ) { \
58 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 58 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
59 if ( maximized ) { \ 59 if ( maximized ) { \
60 if ( qApp->desktop()->width() <= 350 ) { \ 60 if ( qApp->desktop()->width() <= 350 ) { \
61 w->showMaximized(); \ 61 w->showMaximized(); \
62 } else { \ 62 } else { \
63 w->resize( QSize( 300, 300 ) ); \ 63 w->resize( QSize( 300, 300 ) ); \
64 } \ 64 } \
65 } \ 65 } \
66 w->show(); \ 66 w->show(); \
67 return w; \ 67 return w; \
68 } 68 }
69 69
70 70
71#ifdef SINGLE_APP 71#ifdef SINGLE_APP
72#define APP(a,b,c,d) FACTORY(b) 72#define APP(a,b,c,d) FACTORY(b)
73#include "../launcher/apps.h" 73#include "../launcher/apps.h"
74#undef APP 74#undef APP
75#endif // SINGLE_APP 75#endif // SINGLE_APP
76 76
77static Global::Command builtins[] = { 77static Global::Command builtins[] = {
78 78
79#ifdef SINGLE_APP 79#ifdef SINGLE_APP
80#define APP(a,b,c,d) { a, new##b, c }, 80#define APP(a,b,c,d) { a, new##b, c },
81#include "../launcher/apps.h" 81#include "../launcher/apps.h"
82#undef APP 82#undef APP
83#endif 83#endif
84 84
85#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) 85#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX)
86 { "calibrate", TaskBar::calibrate, 1, 0 }, 86 { "calibrate", TaskBar::calibrate, 1, 0 },
87#endif 87#endif
88#if !defined(QT_QWS_CASSIOPEIA) 88#if !defined(QT_QWS_CASSIOPEIA)
89 { "shutdown", Global::shutdown, 1, 0 }, 89 { "shutdown", Global::shutdown, 1, 0 },
90// { "run", run, 1, 0 }, 90// { "run", run, 1, 0 },
91#endif 91#endif
92 92
93 { 0, TaskBar::calibrate, 0, 0 }, 93 { 0, TaskBar::calibrate, 0, 0 },
94}; 94};
95 95
96static bool initNumLock() 96static bool initNumLock()
97{ 97{
98#ifdef QPE_INITIAL_NUMLOCK_STATE 98#ifdef QPE_INITIAL_NUMLOCK_STATE
99 QPE_INITIAL_NUMLOCK_STATE 99 QPE_INITIAL_NUMLOCK_STATE
100#endif 100#endif
101 return FALSE; 101 return FALSE;
102} 102}
103 103
104class LockKeyState : public QWidget 104class LockKeyState : public QWidget
105{ 105{
106public: 106public:
107 LockKeyState( QWidget *parent ) : 107 LockKeyState( QWidget *parent ) :
108 QWidget(parent), 108 QWidget(parent),
109 nl(initNumLock()), cl(FALSE) 109 nl(initNumLock()), cl(FALSE)
110 { 110 {
111 nl_pm = Resource::loadPixmap("numlock"); 111 nl_pm = Resource::loadPixmap("numlock");
112 cl_pm = Resource::loadPixmap("capslock"); 112 cl_pm = Resource::loadPixmap("capslock");
113 } 113 }
114 QSize sizeHint() const 114 QSize sizeHint() const
115 { 115 {
116 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 116 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
117 } 117 }
118 void toggleNumLockState() 118 void toggleNumLockState()
119 { 119 {
120 nl = !nl; repaint(); 120 nl = !nl; repaint();
121 } 121 }
122 void toggleCapsLockState() 122 void toggleCapsLockState()
123 { 123 {
124 cl = !cl; repaint(); 124 cl = !cl; repaint();
125 } 125 }
126 void paintEvent( QPaintEvent * ) 126 void paintEvent( QPaintEvent * )
127 { 127 {
128 int y = (height()-sizeHint().height())/2; 128 int y = (height()-sizeHint().height())/2;
129 QPainter p(this); 129 QPainter p(this);
130 if ( nl ) 130 if ( nl )
131 p.drawPixmap(1,y,nl_pm); 131 p.drawPixmap(1,y,nl_pm);
132 if ( cl ) 132 if ( cl )
133 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 133 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
134 } 134 }
135private: 135private:
136 QPixmap nl_pm, cl_pm; 136 QPixmap nl_pm, cl_pm;
137 bool nl, cl; 137 bool nl, cl;
138}; 138};
139 139
140TaskBar::~TaskBar() 140TaskBar::~TaskBar()
141{ 141{
142} 142}
143 143
144 144
145TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 145TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
146{ 146{
147 Global::setBuiltinCommands(builtins); 147 Global::setBuiltinCommands(builtins);
148 148
149 sm = new StartMenu( this ); 149 sm = new StartMenu( this );
150 150
151 inputMethods = new InputMethods( this ); 151 inputMethods = new InputMethods( this );
152 connect( inputMethods, SIGNAL(inputToggled(bool)), 152 connect( inputMethods, SIGNAL(inputToggled(bool)),
153 this, SLOT(calcMaxWindowRect()) ); 153 this, SLOT(calcMaxWindowRect()) );
154 //new QuickLauncher( this ); 154 //new QuickLauncher( this );
155 155
156 stack = new QWidgetStack( this ); 156 stack = new QWidgetStack( this );
157 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 157 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
158 label = new QLabel(stack); 158 label = new QLabel(stack);
159 159
160 //mru = new MRUList( stack ); 160 //mru = new MRUList( stack );
161 //stack->raiseWidget( mru ); 161 //stack->raiseWidget( mru );
162 162
163 runningAppBar = new RunningAppBar(stack); 163 runningAppBar = new RunningAppBar(stack);
164 stack->raiseWidget(runningAppBar); 164 stack->raiseWidget(runningAppBar);
165 165
166 waitIcon = new Wait( this ); 166 waitIcon = new Wait( this );
167 (void) new AppIcons( this ); 167 (void) new AppIcons( this );
168 168
169 sysTray = new SysTray( this ); 169 sysTray = new SysTray( this );
170 170
171 // ## make customizable in some way? 171 // ## make customizable in some way?
172#ifdef QT_QWS_CUSTOM 172#ifdef QT_QWS_SHARP
173 lockState = new LockKeyState( this ); 173 lockState = new LockKeyState( this );
174#else 174#else
175 lockState = 0; 175 lockState = 0;
176#endif 176#endif
177 177
178#if defined(Q_WS_QWS) 178#if defined(Q_WS_QWS)
179#if !defined(QT_NO_COP) 179#if !defined(QT_NO_COP)
180 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 180 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
181 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 181 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
182 this, SLOT(receive(const QCString&, const QByteArray&)) ); 182 this, SLOT(receive(const QCString&, const QByteArray&)) );
183#endif 183#endif
184#endif 184#endif
185 waitTimer = new QTimer( this ); 185 waitTimer = new QTimer( this );
186 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 186 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
187 clearer = new QTimer( this ); 187 clearer = new QTimer( this );
188 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 188 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
189 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); 189 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show()));
190} 190}
191 191
192void TaskBar::setStatusMessage( const QString &text ) 192void TaskBar::setStatusMessage( const QString &text )
193{ 193{
194 if ( !text.isEmpty() ) { 194 if ( !text.isEmpty() ) {
195 label->setText( text ); 195 label->setText( text );
196 stack->raiseWidget( label ); 196 stack->raiseWidget( label );
197 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 197 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
198 sysTray->hide(); 198 sysTray->hide();
199 clearer->start( 3000, TRUE ); 199 clearer->start( 3000, TRUE );
200 } else { 200 } else {
201 clearStatusBar(); 201 clearStatusBar();
202 } 202 }
203} 203}
204 204
205void TaskBar::clearStatusBar() 205void TaskBar::clearStatusBar()
206{ 206{
207 label->clear(); 207 label->clear();
208 stack->raiseWidget(runningAppBar); 208 stack->raiseWidget(runningAppBar);
209 // stack->raiseWidget( mru ); 209 // stack->raiseWidget( mru );
210} 210}
211 211
212void TaskBar::startWait() 212void TaskBar::startWait()
213{ 213{
214 waitIcon->setWaiting( true ); 214 waitIcon->setWaiting( true );
215 // a catchall stop after 10 seconds... 215 // a catchall stop after 10 seconds...
216 waitTimer->start( 10 * 1000, true ); 216 waitTimer->start( 10 * 1000, true );
217} 217}
218 218
219void TaskBar::stopWait(const QString& /*app*/) 219void TaskBar::stopWait(const QString& /*app*/)
220{ 220{
221 waitTimer->stop(); 221 waitTimer->stop();
222 //mru->addTask(sm->execToLink(app)); 222 //mru->addTask(sm->execToLink(app));
223 waitIcon->setWaiting( false ); 223 waitIcon->setWaiting( false );
224} 224}
225 225
226void TaskBar::stopWait() 226void TaskBar::stopWait()
227{ 227{
228 waitTimer->stop(); 228 waitTimer->stop();
229 229
230 waitIcon->setWaiting( false ); 230 waitIcon->setWaiting( false );
231} 231}
232 232
233void TaskBar::resizeEvent( QResizeEvent *e ) 233void TaskBar::resizeEvent( QResizeEvent *e )
234{ 234{
235 QHBox::resizeEvent( e ); 235 QHBox::resizeEvent( e );
236 calcMaxWindowRect(); 236 calcMaxWindowRect();
237} 237}
238 238
239void TaskBar::styleChange( QStyle &s ) 239void TaskBar::styleChange( QStyle &s )
240{ 240{
241 QHBox::styleChange( s ); 241 QHBox::styleChange( s );
242 calcMaxWindowRect(); 242 calcMaxWindowRect();
243} 243}
244 244
245void TaskBar::calcMaxWindowRect() 245void TaskBar::calcMaxWindowRect()
246{ 246{
247#ifdef Q_WS_QWS 247#ifdef Q_WS_QWS
248 QRect wr; 248 QRect wr;
249 int displayWidth = qApp->desktop()->width(); 249 int displayWidth = qApp->desktop()->width();
250 QRect ir = inputMethods->inputRect(); 250 QRect ir = inputMethods->inputRect();
251 if ( ir.isValid() ) { 251 if ( ir.isValid() ) {
252 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 252 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
253 } else { 253 } else {
254 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 254 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
255 } 255 }
256 256
257#if QT_VERSION < 300 257#if QT_VERSION < 300
258 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 258 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
259 QSize(qt_screen->width(),qt_screen->height())) 259 QSize(qt_screen->width(),qt_screen->height()))
260 ); 260 );
261#else 261#else
262 QWSServer::setMaxWindowRect( wr ); 262 QWSServer::setMaxWindowRect( wr );
263#endif 263#endif
264#endif 264#endif
265} 265}
266 266
267void TaskBar::receive( const QCString &msg, const QByteArray &data ) 267void TaskBar::receive( const QCString &msg, const QByteArray &data )
268{ 268{
269 QDataStream stream( data, IO_ReadOnly ); 269 QDataStream stream( data, IO_ReadOnly );
270 if ( msg == "message(QString)" ) { 270 if ( msg == "message(QString)" ) {
271 QString text; 271 QString text;
272 stream >> text; 272 stream >> text;
273 setStatusMessage( text ); 273 setStatusMessage( text );
274 } else if ( msg == "hideInputMethod()" ) { 274 } else if ( msg == "hideInputMethod()" ) {
275 inputMethods->hideInputMethod(); 275 inputMethods->hideInputMethod();
276 } else if ( msg == "showInputMethod()" ) { 276 } else if ( msg == "showInputMethod()" ) {
277 inputMethods->showInputMethod(); 277 inputMethods->showInputMethod();
278 } else if ( msg == "reloadInputMethods()" ) { 278 } else if ( msg == "reloadInputMethods()" ) {
279 inputMethods->loadInputMethods(); 279 inputMethods->loadInputMethods();
280 } else if ( msg == "reloadApps()" ) { 280 } else if ( msg == "reloadApps()" ) {
281 sm->reloadApps(); 281 sm->reloadApps();
282 } else if ( msg == "reloadApplets()" ) { 282 } else if ( msg == "reloadApplets()" ) {
283 sysTray->clearApplets(); 283 sysTray->clearApplets();
284 sysTray->addApplets(); 284 sysTray->addApplets();
285 sm->reloadApplets(); 285 sm->reloadApplets();
286 } else if ( msg == "soundAlarm()" ) { 286 } else if ( msg == "soundAlarm()" ) {
287 Desktop::soundAlarm(); 287 Desktop::soundAlarm();
288 } 288 }
289 else if ( msg == "setLed(int,bool)" ) { 289 else if ( msg == "setLed(int,bool)" ) {
290 int led, status; 290 int led, status;
291 stream >> led >> status; 291 stream >> led >> status;
292 292
293 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 293 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
294 if ( ll. count ( )){ 294 if ( ll. count ( )){
295 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 295 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
296 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 296 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
297 297
298 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); 298 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
299 } 299 }
300 } 300 }
301} 301}
302 302
303QWidget *TaskBar::calibrate(bool) 303QWidget *TaskBar::calibrate(bool)
304{ 304{
305#ifdef Q_WS_QWS 305#ifdef Q_WS_QWS
306 Calibrate *c = new Calibrate; 306 Calibrate *c = new Calibrate;
307 c->show(); 307 c->show();
308 return c; 308 return c;
309#else 309#else
310 return 0; 310 return 0;
311#endif 311#endif
312} 312}
313 313
314void TaskBar::toggleNumLockState() 314void TaskBar::toggleNumLockState()
315{ 315{
316 if ( lockState ) lockState->toggleNumLockState(); 316 if ( lockState ) lockState->toggleNumLockState();
317} 317}
318 318
319void TaskBar::toggleCapsLockState() 319void TaskBar::toggleCapsLockState()
320{ 320{
321 if ( lockState ) lockState->toggleCapsLockState(); 321 if ( lockState ) lockState->toggleCapsLockState();
322} 322}
323 323
324void TaskBar::toggleSymbolInput() 324void TaskBar::toggleSymbolInput()
325{ 325{
326 if ( inputMethods->currentShown() == "Unicode" ) { 326 if ( inputMethods->currentShown() == "Unicode" ) {
327 inputMethods->hideInputMethod(); 327 inputMethods->hideInputMethod();
328 } else { 328 } else {
329 inputMethods->showInputMethod("Unicode"); 329 inputMethods->showInputMethod("Unicode");
330 } 330 }
331} 331}
332 332
333bool TaskBar::recoverMemory() 333bool TaskBar::recoverMemory()
334{ 334{
335 //eturn mru->quitOldApps(); 335 //eturn mru->quitOldApps();
336 return true; 336 return true;
337} 337}
338 338
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index c7dc7a8..1b89bc8 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -1,625 +1,625 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#define _REENTRANT 20#define _REENTRANT
21 21
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qimage.h> 23#include <qimage.h>
24#include <qpainter.h> 24#include <qpainter.h>
25#ifdef Q_WS_QWS 25#ifdef Q_WS_QWS
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#endif 27#endif
28#include "mediaplayerplugininterface.h" 28#include "mediaplayerplugininterface.h"
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <string.h> 31#include <string.h>
32#include <time.h> 32#include <time.h>
33#include <unistd.h> 33#include <unistd.h>
34#include <pthread.h> 34#include <pthread.h>
35#include "loopcontrol.h" 35#include "loopcontrol.h"
36#include "audiodevice.h" 36#include "audiodevice.h"
37#include "videowidget.h" 37#include "videowidget.h"
38#include "audiowidget.h" 38#include "audiowidget.h"
39#include "mediaplayerstate.h" 39#include "mediaplayerstate.h"
40 40
41 41
42#if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ) 42#if defined(QT_QWS_SHARP) || defined(QT_QWS_IPAQ)
43#define USE_REALTIME_AUDIO_THREAD 43#define USE_REALTIME_AUDIO_THREAD
44#endif 44#endif
45 45
46 46
47extern VideoWidget *videoUI; // now only needed to tell it to play a frame 47extern VideoWidget *videoUI; // now only needed to tell it to play a frame
48extern MediaPlayerState *mediaPlayerState; 48extern MediaPlayerState *mediaPlayerState;
49 49
50 50
51#define DecodeLoopDebug(x) qDebug x 51#define DecodeLoopDebug(x) qDebug x
52//#define DecodeLoopDebug(x) 52//#define DecodeLoopDebug(x)
53 53
54 54
55 static char *audioBuffer = NULL; 55 static char *audioBuffer = NULL;
56static AudioDevice *audioDevice = NULL; 56static AudioDevice *audioDevice = NULL;
57 static bool disabledSuspendScreenSaver = FALSE; 57 static bool disabledSuspendScreenSaver = FALSE;
58 58
59 59
60 pthread_tvideo_tid; 60 pthread_tvideo_tid;
61pthread_attr_t video_attr; 61pthread_attr_t video_attr;
62 pthread_taudio_tid; 62 pthread_taudio_tid;
63pthread_attr_t audio_attr; 63pthread_attr_t audio_attr;
64 64
65 65
66bool emitPlayFinished = FALSE; 66bool emitPlayFinished = FALSE;
67bool emitChangePos = FALSE; 67bool emitChangePos = FALSE;
68 68
69 69
70class Mutex { 70class Mutex {
71public: 71public:
72 Mutex() { 72 Mutex() {
73 pthread_mutexattr_t attr; 73 pthread_mutexattr_t attr;
74 pthread_mutexattr_init( &attr ); 74 pthread_mutexattr_init( &attr );
75 pthread_mutex_init( &mutex, &attr ); 75 pthread_mutex_init( &mutex, &attr );
76 pthread_mutexattr_destroy( &attr ); 76 pthread_mutexattr_destroy( &attr );
77 } 77 }
78 78
79 ~Mutex() { 79 ~Mutex() {
80 pthread_mutex_destroy( &mutex ); 80 pthread_mutex_destroy( &mutex );
81 } 81 }
82 82
83 void lock() { 83 void lock() {
84 pthread_mutex_lock( &mutex ); 84 pthread_mutex_lock( &mutex );
85 } 85 }
86 86
87 void unlock() { 87 void unlock() {
88 pthread_mutex_unlock( &mutex ); 88 pthread_mutex_unlock( &mutex );
89 } 89 }
90/* 90/*
91 bool locked() { 91 bool locked() {
92 switch ( pthread_mutex_trylock( &mutex ) ) { 92 switch ( pthread_mutex_trylock( &mutex ) ) {
93 case EBUSY: 93 case EBUSY:
94 return TRUE; 94 return TRUE;
95 case 0: 95 case 0:
96 pthread_mutex_unlock( &mutex ); 96 pthread_mutex_unlock( &mutex );
97 default: 97 default:
98 return FALSE; 98 return FALSE;
99 } 99 }
100 } 100 }
101*/ 101*/
102private: 102private:
103 pthread_mutex_t mutex; 103 pthread_mutex_t mutex;
104}; 104};
105 105
106 106
107class currentFrameObj { 107class currentFrameObj {
108public: 108public:
109 currentFrameObj() : value( 0 ) { } 109 currentFrameObj() : value( 0 ) { }
110 void set( long f ) { 110 void set( long f ) {
111 mutex.lock(); 111 mutex.lock();
112 value = f; 112 value = f;
113 mediaPlayerState->curDecoder()->videoSetFrame( f, 0 ); 113 mediaPlayerState->curDecoder()->videoSetFrame( f, 0 );
114 mutex.unlock(); 114 mutex.unlock();
115 } 115 }
116 long get() { 116 long get() {
117 return value; 117 return value;
118 } 118 }
119private: 119private:
120 long value; 120 long value;
121 Mutex mutex; 121 Mutex mutex;
122}; 122};
123 123
124 124
125Mutex *videoMutex; 125Mutex *videoMutex;
126Mutex *audioMutex; 126Mutex *audioMutex;
127Mutex *globalMutex; 127Mutex *globalMutex;
128 128
129 129
130 clock_tbegin; 130 clock_tbegin;
131 131
132 132
133LoopControl::LoopControl( QObject *parent, const char *name ) 133LoopControl::LoopControl( QObject *parent, const char *name )
134 : QObject( parent, name ) { 134 : QObject( parent, name ) {
135 isMuted = FALSE; 135 isMuted = FALSE;
136 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 136 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
137 timerid = startTimer( 200 ); 137 timerid = startTimer( 200 );
138 videoMutex = new Mutex; 138 videoMutex = new Mutex;
139 audioMutex = new Mutex; 139 audioMutex = new Mutex;
140 globalMutex = new Mutex; 140 globalMutex = new Mutex;
141 //begin = clock(); 141 //begin = clock();
142} 142}
143 143
144 144
145LoopControl::~LoopControl() { 145LoopControl::~LoopControl() {
146 stop(); 146 stop();
147 killTimer( timerid ); 147 killTimer( timerid );
148} 148}
149 149
150 150
151static bool sendingNewPos = FALSE; 151static bool sendingNewPos = FALSE;
152static long prev_frame = 0; 152static long prev_frame = 0;
153static int currentSample = 0; 153static int currentSample = 0;
154 154
155 155
156void LoopControl::timerEvent( QTimerEvent* ) { 156void LoopControl::timerEvent( QTimerEvent* ) {
157 // We need to emit playFinished from the main thread, not one of the 157 // We need to emit playFinished from the main thread, not one of the
158 // decoding threads else we'll have all kinds of yucky things happen (reentrance). 158 // decoding threads else we'll have all kinds of yucky things happen (reentrance).
159 // playFinished will eventually call stop() which stops these threads. 159 // playFinished will eventually call stop() which stops these threads.
160 if ( emitPlayFinished ) { 160 if ( emitPlayFinished ) {
161 emitPlayFinished = FALSE; 161 emitPlayFinished = FALSE;
162 mediaPlayerState->setPlaying( FALSE ); 162 mediaPlayerState->setPlaying( FALSE );
163 } 163 }
164 164
165 if ( emitChangePos ) { 165 if ( emitChangePos ) {
166 166
167 emitChangePos = FALSE; 167 emitChangePos = FALSE;
168 168
169 if ( hasVideoChannel && hasAudioChannel ) { 169 if ( hasVideoChannel && hasAudioChannel ) {
170 sendingNewPos = TRUE; 170 sendingNewPos = TRUE;
171 mediaPlayerState->setPosition( current_frame ); 171 mediaPlayerState->setPosition( current_frame );
172 } else if ( hasVideoChannel ) { 172 } else if ( hasVideoChannel ) {
173 sendingNewPos = TRUE; 173 sendingNewPos = TRUE;
174 mediaPlayerState->setPosition( current_frame ); 174 mediaPlayerState->setPosition( current_frame );
175 } else if ( hasAudioChannel ) { 175 } else if ( hasAudioChannel ) {
176 sendingNewPos = TRUE; 176 sendingNewPos = TRUE;
177 mediaPlayerState->setPosition( audioSampleCounter ); 177 mediaPlayerState->setPosition( audioSampleCounter );
178 } 178 }
179 179
180 } 180 }
181} 181}
182 182
183 183
184 184
185 185
186void LoopControl::setPosition( long pos ) { 186void LoopControl::setPosition( long pos ) {
187 if ( sendingNewPos ) { 187 if ( sendingNewPos ) {
188 sendingNewPos = FALSE; 188 sendingNewPos = FALSE;
189 return; 189 return;
190 } 190 }
191 191
192 if ( hasVideoChannel && hasAudioChannel ) { 192 if ( hasVideoChannel && hasAudioChannel ) {
193 videoMutex->lock(); 193 videoMutex->lock();
194 audioMutex->lock(); 194 audioMutex->lock();
195qDebug("setting position"); 195qDebug("setting position");
196 playtime.restart(); 196 playtime.restart();
197 playtime = playtime.addMSecs( -pos * 1000 / framerate ); 197 playtime = playtime.addMSecs( -pos * 1000 / framerate );
198 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; 198 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
199 current_frame = pos + 1; 199 current_frame = pos + 1;
200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
201 prev_frame = current_frame - 1; 201 prev_frame = current_frame - 1;
202 currentSample = (int)( current_frame * freq / framerate ); 202 currentSample = (int)( current_frame * freq / framerate );
203 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 203 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
204 audioSampleCounter = currentSample - 1; 204 audioSampleCounter = currentSample - 1;
205 audioMutex->unlock(); 205 audioMutex->unlock();
206 videoMutex->unlock(); 206 videoMutex->unlock();
207 } else if ( hasVideoChannel ) { 207 } else if ( hasVideoChannel ) {
208 videoMutex->lock(); 208 videoMutex->lock();
209 playtime.restart(); 209 playtime.restart();
210 playtime = playtime.addMSecs( -pos * 1000 / framerate ); 210 playtime = playtime.addMSecs( -pos * 1000 / framerate );
211 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; 211 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
212 current_frame = pos + 1; 212 current_frame = pos + 1;
213 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 213 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
214 videoMutex->unlock(); 214 videoMutex->unlock();
215 prev_frame = current_frame - 1; 215 prev_frame = current_frame - 1;
216 } else if ( hasAudioChannel ) { 216 } else if ( hasAudioChannel ) {
217 audioMutex->lock(); 217 audioMutex->lock();
218 playtime.restart(); 218 playtime.restart();
219 playtime = playtime.addMSecs( -pos * 1000 / freq ); 219 playtime = playtime.addMSecs( -pos * 1000 / freq );
220 //begin = clock() - (double)pos * CLOCKS_PER_SEC / freq; 220 //begin = clock() - (double)pos * CLOCKS_PER_SEC / freq;
221 currentSample = pos + 1; // (int)( current_frame * freq / framerate ); 221 currentSample = pos + 1; // (int)( current_frame * freq / framerate );
222 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 222 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
223 audioSampleCounter = currentSample - 1; 223 audioSampleCounter = currentSample - 1;
224 audioMutex->unlock(); 224 audioMutex->unlock();
225 } 225 }
226} 226}
227 227
228 228
229void *startVideoThread( void *ptr ) { 229void *startVideoThread( void *ptr ) {
230 LoopControl *mpegView = (LoopControl *)ptr; 230 LoopControl *mpegView = (LoopControl *)ptr;
231 mpegView->startVideo(); 231 mpegView->startVideo();
232 return 0; 232 return 0;
233} 233}
234 234
235void *startAudioThread( void *ptr ) { 235void *startAudioThread( void *ptr ) {
236 LoopControl *mpegView = (LoopControl *)ptr; 236 LoopControl *mpegView = (LoopControl *)ptr;
237 mpegView->startAudio(); 237 mpegView->startAudio();
238 return 0; 238 return 0;
239} 239}
240 240
241void LoopControl::startVideo() { 241void LoopControl::startVideo() {
242 moreVideo = TRUE; 242 moreVideo = TRUE;
243 243
244 while ( moreVideo ) { 244 while ( moreVideo ) {
245 245
246 if ( mediaPlayerState->curDecoder() && hasVideoChannel ) { 246 if ( mediaPlayerState->curDecoder() && hasVideoChannel ) {
247 247
248 if ( hasAudioChannel && !isMuted ) { 248 if ( hasAudioChannel && !isMuted ) {
249 249
250 bool done = FALSE; 250 bool done = FALSE;
251 251
252 do { 252 do {
253 253
254 254
255/* 255/*
256 videoMutex->lock(); 256 videoMutex->lock();
257 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); 257 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 );
258 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC; 258 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC;
259 259
260 // Sync to Audio 260 // Sync to Audio
261 // current_frame = (long)((double)(audioSampleCounter - 1000) * framerate / (double)freq); 261 // current_frame = (long)((double)(audioSampleCounter - 1000) * framerate / (double)freq);
262 262
263 long mSecsToNextFrame = 0; 263 long mSecsToNextFrame = 0;
264 264
265 if ( current_frame == prev_frame ) { 265 if ( current_frame == prev_frame ) {
266 int nf = current_frame + 1; 266 int nf = current_frame + 1;
267 if ( nf > 0 && nf != total_video_frames ) 267 if ( nf > 0 && nf != total_video_frames )
268 // mSecsToNextFrame = long(double(nf * CLOCKS_PER_SEC) / framerate) - ( clock() - begin ); 268 // mSecsToNextFrame = long(double(nf * CLOCKS_PER_SEC) / framerate) - ( clock() - begin );
269 mSecsToNextFrame = long(double(nf * 1000) / framerate) - ( playtime.elapsed() ); 269 mSecsToNextFrame = long(double(nf * 1000) / framerate) - ( playtime.elapsed() );
270 } 270 }
271 videoMutex->unlock(); 271 videoMutex->unlock();
272 272
273 if ( mSecsToNextFrame ) { 273 if ( mSecsToNextFrame ) {
274 usleep( mSecsToNextFrame ); // wait a bit 274 usleep( mSecsToNextFrame ); // wait a bit
275 275
276 videoMutex->lock(); 276 videoMutex->lock();
277 // This should now be the next frame 277 // This should now be the next frame
278 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); 278 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 );
279 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC; 279 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC;
280 videoMutex->unlock(); 280 videoMutex->unlock();
281 } 281 }
282 282
283 videoMutex->lock(); 283 videoMutex->lock();
284 done = current_frame >= prev_frame; 284 done = current_frame >= prev_frame;
285 videoMutex->unlock(); 285 videoMutex->unlock();
286*/ 286*/
287 videoMutex->lock(); 287 videoMutex->lock();
288 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); 288 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 );
289 done = current_frame >= prev_frame; 289 done = current_frame >= prev_frame;
290 videoMutex->unlock(); 290 videoMutex->unlock();
291 if ( !done ) 291 if ( !done )
292 usleep( 1000 ); // wait a bit 292 usleep( 1000 ); // wait a bit
293 293
294 } while ( !done ); 294 } while ( !done );
295 295
296 // qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate ); 296 // qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate );
297 297
298 } else { 298 } else {
299 videoMutex->lock(); 299 videoMutex->lock();
300 current_frame++; 300 current_frame++;
301 videoMutex->unlock(); 301 videoMutex->unlock();
302 } 302 }
303 303
304 videoMutex->lock(); 304 videoMutex->lock();
305 bool check = current_frame && current_frame > prev_frame; 305 bool check = current_frame && current_frame > prev_frame;
306 videoMutex->unlock(); 306 videoMutex->unlock();
307 307
308 if ( check ) { 308 if ( check ) {
309 videoMutex->lock(); 309 videoMutex->lock();
310 if ( current_frame > prev_frame + 1 ) { 310 if ( current_frame > prev_frame + 1 ) {
311 qDebug("skipped a frame"); 311 qDebug("skipped a frame");
312 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 312 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
313 } 313 }
314 prev_frame = current_frame; 314 prev_frame = current_frame;
315 if ( moreVideo = videoUI->playVideo() ) 315 if ( moreVideo = videoUI->playVideo() )
316 emitChangePos = TRUE; 316 emitChangePos = TRUE;
317 videoMutex->unlock(); 317 videoMutex->unlock();
318 } 318 }
319 319
320 } else 320 } else
321 moreVideo = FALSE; 321 moreVideo = FALSE;
322 322
323 } 323 }
324 324
325 if ( !moreVideo && !moreAudio ) 325 if ( !moreVideo && !moreAudio )
326 emitPlayFinished = TRUE; 326 emitPlayFinished = TRUE;
327 327
328 pthread_exit(NULL); 328 pthread_exit(NULL);
329} 329}
330 330
331void LoopControl::startAudio() { 331void LoopControl::startAudio() {
332 moreAudio = TRUE; 332 moreAudio = TRUE;
333 333
334 while ( moreAudio ) { 334 while ( moreAudio ) {
335 335
336 if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) { 336 if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) {
337 337
338 audioMutex->lock(); 338 audioMutex->lock();
339 currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream ); 339 currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream );
340 340
341 if ( currentSample == 0 ) 341 if ( currentSample == 0 )
342 currentSample = audioSampleCounter + 1; 342 currentSample = audioSampleCounter + 1;
343 343
344 if ( currentSample != audioSampleCounter + 1 ) 344 if ( currentSample != audioSampleCounter + 1 )
345 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 345 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
346 audioMutex->unlock(); 346 audioMutex->unlock();
347 347
348/* 348/*
349 int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000; 349 int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000;
350 350
351 if ( sampleWeShouldBeAt - currentSample > 20000 ) { 351 if ( sampleWeShouldBeAt - currentSample > 20000 ) {
352 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 352 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
353 currentSample = sampleWeShouldBeAt; 353 currentSample = sampleWeShouldBeAt;
354 } 354 }
355*/ 355*/
356 long samplesRead = 0; 356 long samplesRead = 0;
357 357
358 const long samples = 1024; 358 const long samples = 1024;
359 359
360 moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream ); 360 moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream );
361 361
362 audioMutex->lock(); 362 audioMutex->lock();
363 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 363 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
364 //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC; 364 //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC;
365 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 365 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
366 audioMutex->unlock(); 366 audioMutex->unlock();
367 367
368 if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) { 368 if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) {
369 //qDebug("sampleWaitTime: %i", sampleWaitTime); 369 //qDebug("sampleWaitTime: %i", sampleWaitTime);
370 usleep( ( sampleWaitTime * 1000000 ) / ( freq ) ); 370 usleep( ( sampleWaitTime * 1000000 ) / ( freq ) );
371 } else { 371 } else {
372 audioMutex->lock(); 372 audioMutex->lock();
373 if ( sampleWaitTime <= -2000 ) { 373 if ( sampleWaitTime <= -2000 ) {
374 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 374 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
375 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 375 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
376 currentSample = sampleWeShouldBeAt; 376 currentSample = sampleWeShouldBeAt;
377 } 377 }
378 audioMutex->unlock(); 378 audioMutex->unlock();
379 } 379 }
380 380
381 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 381 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
382 382
383 audioMutex->lock(); 383 audioMutex->lock();
384 // audioSampleCounter += samplesRead; 384 // audioSampleCounter += samplesRead;
385 audioSampleCounter = currentSample + samplesRead - 1; 385 audioSampleCounter = currentSample + samplesRead - 1;
386 audioMutex->unlock(); 386 audioMutex->unlock();
387 387
388 if ( !hasVideoChannel ) 388 if ( !hasVideoChannel )
389 emitChangePos = TRUE; 389 emitChangePos = TRUE;
390 390
391 //qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples); 391 //qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples);
392 // qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples); 392 // qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples);
393 moreAudio = audioSampleCounter <= total_audio_samples; 393 moreAudio = audioSampleCounter <= total_audio_samples;
394 394
395 } else { 395 } else {
396 396
397 if ( mediaPlayerState->curDecoder() && hasAudioChannel ) 397 if ( mediaPlayerState->curDecoder() && hasAudioChannel )
398 usleep( 100000 ); // Check every 1/10 sec to see if mute is off 398 usleep( 100000 ); // Check every 1/10 sec to see if mute is off
399 else 399 else
400 moreAudio = FALSE; 400 moreAudio = FALSE;
401 401
402 } 402 }
403 } 403 }
404 404
405 qDebug( "End of file" ); 405 qDebug( "End of file" );
406 406
407 if ( !moreVideo && !moreAudio ) 407 if ( !moreVideo && !moreAudio )
408 emitPlayFinished = TRUE; 408 emitPlayFinished = TRUE;
409 409
410 pthread_exit(NULL); 410 pthread_exit(NULL);
411} 411}
412 412
413void LoopControl::killTimers() { 413void LoopControl::killTimers() {
414 if ( hasVideoChannel ) { 414 if ( hasVideoChannel ) {
415 if ( pthread_self() != video_tid ) { 415 if ( pthread_self() != video_tid ) {
416 if ( pthread_cancel(video_tid) == 0 ) { 416 if ( pthread_cancel(video_tid) == 0 ) {
417 void *thread_result = 0; 417 void *thread_result = 0;
418 if ( pthread_join(video_tid,&thread_result) != 0 ) 418 if ( pthread_join(video_tid,&thread_result) != 0 )
419 qDebug("thread join error 1"); 419 qDebug("thread join error 1");
420 pthread_attr_destroy(&video_attr); 420 pthread_attr_destroy(&video_attr);
421 } 421 }
422 } 422 }
423 } 423 }
424 if ( hasAudioChannel ) { 424 if ( hasAudioChannel ) {
425 if ( pthread_self() != audio_tid ) { 425 if ( pthread_self() != audio_tid ) {
426 if ( pthread_cancel(audio_tid) == 0 ) { 426 if ( pthread_cancel(audio_tid) == 0 ) {
427 void *thread_result = 0; 427 void *thread_result = 0;
428 if ( pthread_join(audio_tid,&thread_result) != 0 ) 428 if ( pthread_join(audio_tid,&thread_result) != 0 )
429 qDebug("thread join error 2"); 429 qDebug("thread join error 2");
430 pthread_attr_destroy(&audio_attr); 430 pthread_attr_destroy(&audio_attr);
431 } 431 }
432 } 432 }
433 } 433 }
434} 434}
435 435
436void LoopControl::startTimers() { 436void LoopControl::startTimers() {
437 moreVideo = FALSE; 437 moreVideo = FALSE;
438 moreAudio = FALSE; 438 moreAudio = FALSE;
439 439
440 if ( hasVideoChannel ) { 440 if ( hasVideoChannel ) {
441 moreVideo = TRUE; 441 moreVideo = TRUE;
442 pthread_attr_init(&video_attr); 442 pthread_attr_init(&video_attr);
443 pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); 443 pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this);
444 } 444 }
445 445
446 if ( hasAudioChannel ) { 446 if ( hasAudioChannel ) {
447 moreAudio = TRUE; 447 moreAudio = TRUE;
448 pthread_attr_init(&audio_attr); 448 pthread_attr_init(&audio_attr);
449#ifdef USE_REALTIME_AUDIO_THREAD 449#ifdef USE_REALTIME_AUDIO_THREAD
450 pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin 450 pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin
451 //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) ); 451 //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) );
452 sched_param params; 452 sched_param params;
453 params.sched_priority = 50; 453 params.sched_priority = 50;
454 pthread_attr_setschedparam(&audio_attr,&params); 454 pthread_attr_setschedparam(&audio_attr,&params);
455#endif 455#endif
456 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 456 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
457 } 457 }
458} 458}
459 459
460 460
461 461
462 462
463void LoopControl::setPaused( bool pause ) { 463void LoopControl::setPaused( bool pause ) {
464 static int whenPaused = 0; 464 static int whenPaused = 0;
465 465
466 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 466 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
467 return; 467 return;
468 468
469 if ( pause ) { 469 if ( pause ) {
470 // Remember where we are 470 // Remember where we are
471 whenPaused = playtime.elapsed(); 471 whenPaused = playtime.elapsed();
472 killTimers(); 472 killTimers();
473 } else { 473 } else {
474 // Just like we never stopped 474 // Just like we never stopped
475 playtime.restart(); 475 playtime.restart();
476 playtime = playtime.addMSecs( -whenPaused ); 476 playtime = playtime.addMSecs( -whenPaused );
477 whenPaused = 0; 477 whenPaused = 0;
478 startTimers(); 478 startTimers();
479 } 479 }
480} 480}
481 481
482 482
483void LoopControl::stop( bool willPlayAgainShortly ) { 483void LoopControl::stop( bool willPlayAgainShortly ) {
484 484
485#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 485#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
486 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 486 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
487 disabledSuspendScreenSaver = FALSE; 487 disabledSuspendScreenSaver = FALSE;
488 // Re-enable the suspend mode 488 // Re-enable the suspend mode
489 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 489 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
490 } 490 }
491#endif 491#endif
492 492
493 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 493 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
494 494
495 killTimers(); 495 killTimers();
496 496
497 mediaPlayerState->curDecoder()->close(); 497 mediaPlayerState->curDecoder()->close();
498 498
499 if ( audioDevice ) { 499 if ( audioDevice ) {
500 delete audioDevice; 500 delete audioDevice;
501 delete audioBuffer; 501 delete audioBuffer;
502 audioDevice = 0; 502 audioDevice = 0;
503 audioBuffer = 0; 503 audioBuffer = 0;
504 } 504 }
505 505
506 } 506 }
507} 507}
508 508
509 509
510bool LoopControl::init( const QString& filename ) { 510bool LoopControl::init( const QString& filename ) {
511 stop(); 511 stop();
512 fileName = filename; 512 fileName = filename;
513 stream = 0; // only play stream 0 for now 513 stream = 0; // only play stream 0 for now
514 current_frame = total_video_frames = total_audio_samples = 0; 514 current_frame = total_video_frames = total_audio_samples = 0;
515 515
516 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 516 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
517 517
518 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 518 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
519 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 519 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
520 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 520 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
521 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 521 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
522 mediaPlayerState->libMpeg3Decoder()->close(); 522 mediaPlayerState->libMpeg3Decoder()->close();
523 } 523 }
524 } 524 }
525 525
526 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) 526 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) )
527 return FALSE; 527 return FALSE;
528 528
529 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 529 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
530 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 530 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
531 531
532 if ( hasAudioChannel ) { 532 if ( hasAudioChannel ) {
533 int astream = 0; 533 int astream = 0;
534 534
535 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 535 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
536 DecodeLoopDebug(( "channels = %d\n", channels )); 536 DecodeLoopDebug(( "channels = %d\n", channels ));
537 537
538 if ( !total_audio_samples ) 538 if ( !total_audio_samples )
539 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 539 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
540 540
541 mediaPlayerState->setLength( total_audio_samples ); 541 mediaPlayerState->setLength( total_audio_samples );
542 542
543 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 543 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
544 DecodeLoopDebug(( "frequency = %d\n", freq )); 544 DecodeLoopDebug(( "frequency = %d\n", freq ));
545 545
546 audioSampleCounter = 0; 546 audioSampleCounter = 0;
547 547
548 static const int bytes_per_sample = 2; //16 bit 548 static const int bytes_per_sample = 2; //16 bit
549 549
550 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 550 audioDevice = new AudioDevice( freq, channels, bytes_per_sample );
551 audioBuffer = new char[ audioDevice->bufferSize() ]; 551 audioBuffer = new char[ audioDevice->bufferSize() ];
552 channels = audioDevice->channels(); 552 channels = audioDevice->channels();
553 553
554 //### must check which frequency is actually used. 554 //### must check which frequency is actually used.
555 static const int size = 1; 555 static const int size = 1;
556 short int buf[size]; 556 short int buf[size];
557 long samplesRead = 0; 557 long samplesRead = 0;
558 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 558 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
559 } 559 }
560 560
561 if ( hasVideoChannel ) { 561 if ( hasVideoChannel ) {
562 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 562 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
563 563
564 mediaPlayerState->setLength( total_video_frames ); 564 mediaPlayerState->setLength( total_video_frames );
565 565
566 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 566 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
567 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 567 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
568 568
569 if ( framerate <= 1.0 ) { 569 if ( framerate <= 1.0 ) {
570 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 570 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
571 framerate = 25; 571 framerate = 25;
572 } 572 }
573 573
574 if ( total_video_frames == 1 ) { 574 if ( total_video_frames == 1 ) {
575 DecodeLoopDebug(( "Cannot seek to frame" )); 575 DecodeLoopDebug(( "Cannot seek to frame" ));
576 } 576 }
577 577
578 } 578 }
579 579
580 videoMutex->lock(); 580 videoMutex->lock();
581 current_frame = 0; 581 current_frame = 0;
582 prev_frame = -1; 582 prev_frame = -1;
583 videoMutex->unlock(); 583 videoMutex->unlock();
584 584
585 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 585 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
586 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 586 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
587 587
588 //setBackgroundColor( black ); 588 //setBackgroundColor( black );
589 return TRUE; 589 return TRUE;
590} 590}
591 591
592 592
593void LoopControl::play() { 593void LoopControl::play() {
594 594
595#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 595#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
596 if ( !disabledSuspendScreenSaver ) { 596 if ( !disabledSuspendScreenSaver ) {
597 disabledSuspendScreenSaver = TRUE; 597 disabledSuspendScreenSaver = TRUE;
598 // Stop the screen from blanking and power saving state 598 // Stop the screen from blanking and power saving state
599 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 599 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
600 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 600 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
601 } 601 }
602#endif 602#endif
603 603
604 //begin = clock(); 604 //begin = clock();
605 playtime.start(); 605 playtime.start();
606 startTimers(); 606 startTimers();
607 //updateGeometry(); 607 //updateGeometry();
608} 608}
609 609
610 610
611void LoopControl::setMute( bool on ) { 611void LoopControl::setMute( bool on ) {
612 if ( isMuted != on ) { 612 if ( isMuted != on ) {
613 isMuted = on; 613 isMuted = on;
614 if ( isMuted ) { 614 if ( isMuted ) {
615 } else { 615 } else {
616 int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); 616 int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream );
617 playtime.restart(); 617 playtime.restart();
618 playtime = playtime.addMSecs( -frame * 1000 / framerate ); 618 playtime = playtime.addMSecs( -frame * 1000 / framerate );
619 //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; 619 //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate;
620 mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); 620 mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream );
621 } 621 }
622 } 622 }
623} 623}
624 624
625 625
diff --git a/library/alarmserver.cpp b/library/alarmserver.cpp
index 02bca3d..7e6e515 100644
--- a/library/alarmserver.cpp
+++ b/library/alarmserver.cpp
@@ -1,401 +1,401 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qdir.h> 21#include <qdir.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25 25
26 26
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include "global.h" 28#include "global.h"
29#include "resource.h" 29#include "resource.h"
30 30
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32#include "alarmserver.h" 32#include "alarmserver.h"
33#include <qpe/timeconversion.h> 33#include <qpe/timeconversion.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/stat.h> 36#include <sys/stat.h>
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39#include <unistd.h> 39#include <unistd.h>
40 40
41struct timerEventItem { 41struct timerEventItem {
42 time_t UTCtime; 42 time_t UTCtime;
43 QCString channel, message; 43 QCString channel, message;
44 int data; 44 int data;
45 bool operator==( const timerEventItem &right ) const 45 bool operator==( const timerEventItem &right ) const
46 { 46 {
47 return ( UTCtime == right.UTCtime 47 return ( UTCtime == right.UTCtime
48 && channel == right.channel 48 && channel == right.channel
49 && message == right.message 49 && message == right.message
50 && data == right.data ); 50 && data == right.data );
51 } 51 }
52}; 52};
53 53
54class TimerReceiverObject : public QObject 54class TimerReceiverObject : public QObject
55{ 55{
56public: 56public:
57 TimerReceiverObject() { } 57 TimerReceiverObject() { }
58 ~TimerReceiverObject() { } 58 ~TimerReceiverObject() { }
59 void resetTimer(); 59 void resetTimer();
60 void setTimerEventItem(); 60 void setTimerEventItem();
61 void deleteTimer(); 61 void deleteTimer();
62protected: 62protected:
63 void timerEvent( QTimerEvent *te ); 63 void timerEvent( QTimerEvent *te );
64private: 64private:
65 QString atfilename; 65 QString atfilename;
66}; 66};
67 67
68TimerReceiverObject *timerEventReceiver = NULL; 68TimerReceiverObject *timerEventReceiver = NULL;
69QList<timerEventItem> timerEventList; 69QList<timerEventItem> timerEventList;
70timerEventItem *nearestTimerEvent = NULL; 70timerEventItem *nearestTimerEvent = NULL;
71 71
72 72
73// set the timer to go off on the next event in the list 73// set the timer to go off on the next event in the list
74void setNearestTimerEvent() 74void setNearestTimerEvent()
75{ 75{
76 nearestTimerEvent = NULL; 76 nearestTimerEvent = NULL;
77 QListIterator<timerEventItem> it( timerEventList ); 77 QListIterator<timerEventItem> it( timerEventList );
78 if ( *it ) 78 if ( *it )
79 nearestTimerEvent = *it; 79 nearestTimerEvent = *it;
80 for ( ; *it; ++it ) 80 for ( ; *it; ++it )
81 if ( (*it)->UTCtime < nearestTimerEvent->UTCtime ) 81 if ( (*it)->UTCtime < nearestTimerEvent->UTCtime )
82 nearestTimerEvent = *it; 82 nearestTimerEvent = *it;
83 if (nearestTimerEvent) 83 if (nearestTimerEvent)
84 timerEventReceiver->resetTimer(); 84 timerEventReceiver->resetTimer();
85 else 85 else
86 timerEventReceiver->deleteTimer(); 86 timerEventReceiver->deleteTimer();
87} 87}
88 88
89 89
90//store current state to file 90//store current state to file
91//Simple implementation. Should run on a timer. 91//Simple implementation. Should run on a timer.
92 92
93static void saveState() 93static void saveState()
94{ 94{
95 QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); 95 QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" );
96 if ( timerEventList.isEmpty() ) { 96 if ( timerEventList.isEmpty() ) {
97 unlink( savefilename ); 97 unlink( savefilename );
98 return; 98 return;
99 } 99 }
100 100
101 QFile savefile(savefilename+".new"); 101 QFile savefile(savefilename+".new");
102 if ( savefile.open(IO_WriteOnly) ) { 102 if ( savefile.open(IO_WriteOnly) ) {
103 QDataStream ds( &savefile ); 103 QDataStream ds( &savefile );
104 104
105 //save 105 //save
106 106
107 QListIterator<timerEventItem> it( timerEventList ); 107 QListIterator<timerEventItem> it( timerEventList );
108 for ( ; *it; ++it ) { 108 for ( ; *it; ++it ) {
109 ds << it.current()->UTCtime; 109 ds << it.current()->UTCtime;
110 ds << it.current()->channel; 110 ds << it.current()->channel;
111 ds << it.current()->message; 111 ds << it.current()->message;
112 ds << it.current()->data; 112 ds << it.current()->data;
113 } 113 }
114 114
115 115
116 savefile.close(); 116 savefile.close();
117 unlink( savefilename ); 117 unlink( savefilename );
118 QDir d; d.rename(savefilename+".new",savefilename); 118 QDir d; d.rename(savefilename+".new",savefilename);
119 119
120 } 120 }
121} 121}
122 122
123/*! 123/*!
124 Sets up the alarm server. Restoring to previous state (session management). 124 Sets up the alarm server. Restoring to previous state (session management).
125 */ 125 */
126void AlarmServer::initialize() 126void AlarmServer::initialize()
127{ 127{
128 //read autosave file and put events in timerEventList 128 //read autosave file and put events in timerEventList
129 129
130 QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" ); 130 QString savefilename = Global::applicationFileName( "AlarmServer", "saveFile" );
131 131
132 QFile savefile(savefilename); 132 QFile savefile(savefilename);
133 if ( savefile.open(IO_ReadOnly) ) { 133 if ( savefile.open(IO_ReadOnly) ) {
134 QDataStream ds( &savefile ); 134 QDataStream ds( &savefile );
135 while ( !ds.atEnd() ) { 135 while ( !ds.atEnd() ) {
136 timerEventItem *newTimerEventItem = new timerEventItem; 136 timerEventItem *newTimerEventItem = new timerEventItem;
137 ds >> newTimerEventItem->UTCtime; 137 ds >> newTimerEventItem->UTCtime;
138 ds >> newTimerEventItem->channel; 138 ds >> newTimerEventItem->channel;
139 ds >> newTimerEventItem->message; 139 ds >> newTimerEventItem->message;
140 ds >> newTimerEventItem->data; 140 ds >> newTimerEventItem->data;
141 timerEventList.append( newTimerEventItem ); 141 timerEventList.append( newTimerEventItem );
142 } 142 }
143 savefile.close(); 143 savefile.close();
144 if (!timerEventReceiver) 144 if (!timerEventReceiver)
145 timerEventReceiver = new TimerReceiverObject; 145 timerEventReceiver = new TimerReceiverObject;
146 setNearestTimerEvent(); 146 setNearestTimerEvent();
147 } 147 }
148} 148}
149 149
150 150
151 151
152 152
153static const char* atdir = "/var/spool/at/"; 153static const char* atdir = "/var/spool/at/";
154 154
155static bool triggerAtd( bool writeHWClock = FALSE ) 155static bool triggerAtd( bool writeHWClock = FALSE )
156{ 156{
157 QFile trigger(QString(atdir) + "trigger"); 157 QFile trigger(QString(atdir) + "trigger");
158 if ( trigger.open(IO_WriteOnly|IO_Raw) ) { 158 if ( trigger.open(IO_WriteOnly|IO_Raw) ) {
159 159
160 const char* data = 160 const char* data =
161#ifdef QT_QWS_CUSTOM 161#ifdef QT_QWS_SHARP
162 //custom atd only writes HW Clock if we write a 'W' 162 //custom atd only writes HW Clock if we write a 'W'
163 ( writeHWClock ) ? "W\n" : 163 ( writeHWClock ) ? "W\n" :
164#endif 164#endif
165 data = "\n"; 165 data = "\n";
166 int len = strlen(data); 166 int len = strlen(data);
167 int total_written = trigger.writeBlock(data,len); 167 int total_written = trigger.writeBlock(data,len);
168 if ( total_written != len ) { 168 if ( total_written != len ) {
169 QMessageBox::critical( 0, QObject::tr( "Out of Space" ), 169 QMessageBox::critical( 0, QObject::tr( "Out of Space" ),
170 QObject::tr( "Unable to schedule alarm.\nFree some memory and try again." ) ); 170 QObject::tr( "Unable to schedule alarm.\nFree some memory and try again." ) );
171 trigger.close(); 171 trigger.close();
172 QFile::remove( trigger.name() ); 172 QFile::remove( trigger.name() );
173 return FALSE; 173 return FALSE;
174 } 174 }
175 return TRUE; 175 return TRUE;
176 } 176 }
177 return FALSE; 177 return FALSE;
178} 178}
179 179
180void TimerReceiverObject::deleteTimer() 180void TimerReceiverObject::deleteTimer()
181{ 181{
182 if ( !atfilename.isEmpty() ) { 182 if ( !atfilename.isEmpty() ) {
183 unlink( atfilename ); 183 unlink( atfilename );
184 atfilename = QString::null; 184 atfilename = QString::null;
185 triggerAtd( FALSE ); 185 triggerAtd( FALSE );
186 } 186 }
187} 187}
188 188
189void TimerReceiverObject::resetTimer() 189void TimerReceiverObject::resetTimer()
190{ 190{
191 const int maxsecs = 2147000; 191 const int maxsecs = 2147000;
192 int total_written; 192 int total_written;
193 QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime); 193 QDateTime nearest = TimeConversion::fromUTC(nearestTimerEvent->UTCtime);
194 QDateTime now = QDateTime::currentDateTime(); 194 QDateTime now = QDateTime::currentDateTime();
195 if ( nearest < now ) 195 if ( nearest < now )
196 nearest = now; 196 nearest = now;
197 int secs = TimeConversion::secsTo( now, nearest ); 197 int secs = TimeConversion::secsTo( now, nearest );
198 if ( secs > maxsecs ) { 198 if ( secs > maxsecs ) {
199 // too far for millisecond timing 199 // too far for millisecond timing
200 secs = maxsecs; 200 secs = maxsecs;
201 } 201 }
202 202
203 // System timer (needed so that we wake from deep sleep), 203 // System timer (needed so that we wake from deep sleep),
204 // from the Epoch in seconds. 204 // from the Epoch in seconds.
205 // 205 //
206 int at_secs = TimeConversion::toUTC(nearest); 206 int at_secs = TimeConversion::toUTC(nearest);
207 // qDebug("reset timer to %d seconds from Epoch",at_secs); 207 // qDebug("reset timer to %d seconds from Epoch",at_secs);
208 QString fn = atdir + QString::number(at_secs) + "." 208 QString fn = atdir + QString::number(at_secs) + "."
209 + QString::number(getpid()); 209 + QString::number(getpid());
210 if ( fn != atfilename ) { 210 if ( fn != atfilename ) {
211 QFile atfile(fn+".new"); 211 QFile atfile(fn+".new");
212 if ( atfile.open(IO_WriteOnly|IO_Raw) ) { 212 if ( atfile.open(IO_WriteOnly|IO_Raw) ) {
213 // just wake up and delete the at file 213 // just wake up and delete the at file
214 QString cmd = "#!/bin/sh\nrm " + fn; 214 QString cmd = "#!/bin/sh\nrm " + fn;
215 total_written = atfile.writeBlock(cmd.latin1(),cmd.length()); 215 total_written = atfile.writeBlock(cmd.latin1(),cmd.length());
216 if ( total_written != int(cmd.length()) ) { 216 if ( total_written != int(cmd.length()) ) {
217 QMessageBox::critical( 0, tr("Out of Space"), 217 QMessageBox::critical( 0, tr("Out of Space"),
218 tr("Unable to schedule alarm.\n" 218 tr("Unable to schedule alarm.\n"
219 "Please free up space and try again") ); 219 "Please free up space and try again") );
220 atfile.close(); 220 atfile.close();
221 QFile::remove( atfile.name() ); 221 QFile::remove( atfile.name() );
222 return; 222 return;
223 } 223 }
224 atfile.close(); 224 atfile.close();
225 unlink( atfilename ); 225 unlink( atfilename );
226 QDir d; d.rename(fn+".new",fn); 226 QDir d; d.rename(fn+".new",fn);
227 chmod(fn.latin1(),0755); 227 chmod(fn.latin1(),0755);
228 atfilename = fn; 228 atfilename = fn;
229 triggerAtd( FALSE ); 229 triggerAtd( FALSE );
230 } else { 230 } else {
231 qWarning("Cannot open atd file %s",fn.latin1()); 231 qWarning("Cannot open atd file %s",fn.latin1());
232 } 232 }
233 } 233 }
234 // Qt timers (does the actual alarm) 234 // Qt timers (does the actual alarm)
235 // from now in milliseconds 235 // from now in milliseconds
236 // 236 //
237 qDebug("AlarmServer waiting %d seconds",secs); 237 qDebug("AlarmServer waiting %d seconds",secs);
238 startTimer( 1000 * secs + 500 ); 238 startTimer( 1000 * secs + 500 );
239} 239}
240 240
241void TimerReceiverObject::timerEvent( QTimerEvent * ) 241void TimerReceiverObject::timerEvent( QTimerEvent * )
242{ 242{
243 bool needSave = FALSE; 243 bool needSave = FALSE;
244 killTimers(); 244 killTimers();
245 if (nearestTimerEvent) { 245 if (nearestTimerEvent) {
246 if ( nearestTimerEvent->UTCtime 246 if ( nearestTimerEvent->UTCtime
247 <= TimeConversion::toUTC(QDateTime::currentDateTime()) ) { 247 <= TimeConversion::toUTC(QDateTime::currentDateTime()) ) {
248#ifndef QT_NO_COP 248#ifndef QT_NO_COP
249 QCopEnvelope e( nearestTimerEvent->channel, 249 QCopEnvelope e( nearestTimerEvent->channel,
250 nearestTimerEvent->message ); 250 nearestTimerEvent->message );
251 e << TimeConversion::fromUTC( nearestTimerEvent->UTCtime ) 251 e << TimeConversion::fromUTC( nearestTimerEvent->UTCtime )
252 << nearestTimerEvent->data; 252 << nearestTimerEvent->data;
253#endif 253#endif
254 timerEventList.remove( nearestTimerEvent ); 254 timerEventList.remove( nearestTimerEvent );
255 needSave = TRUE; 255 needSave = TRUE;
256 } 256 }
257 setNearestTimerEvent(); 257 setNearestTimerEvent();
258 } else { 258 } else {
259 resetTimer(); 259 resetTimer();
260 } 260 }
261 if ( needSave ) 261 if ( needSave )
262 saveState(); 262 saveState();
263} 263}
264 264
265/*! 265/*!
266 \class AlarmServer alarmserver.h 266 \class AlarmServer alarmserver.h
267 \brief The AlarmServer class allows alarms to be scheduled and unscheduled. 267 \brief The AlarmServer class allows alarms to be scheduled and unscheduled.
268 268
269 Applications can schedule alarms with addAlarm() and can 269 Applications can schedule alarms with addAlarm() and can
270 unschedule alarms with deleteAlarm(). When the time for an alarm 270 unschedule alarms with deleteAlarm(). When the time for an alarm
271 to go off is reached the specified \link qcop.html QCop\endlink 271 to go off is reached the specified \link qcop.html QCop\endlink
272 message is sent on the specified channel (optionally with 272 message is sent on the specified channel (optionally with
273 additional data). 273 additional data).
274 274
275 Scheduling an alarm using this class is important (rather just using 275 Scheduling an alarm using this class is important (rather just using
276 a QTimer) since the machine may be asleep and needs to get woken up using 276 a QTimer) since the machine may be asleep and needs to get woken up using
277 the Linux kernel which implements this at the kernel level to minimize 277 the Linux kernel which implements this at the kernel level to minimize
278 battery usage while asleep. 278 battery usage while asleep.
279 279
280 \ingroup qtopiaemb 280 \ingroup qtopiaemb
281 \sa QCopEnvelope 281 \sa QCopEnvelope
282*/ 282*/
283 283
284/*! 284/*!
285 Schedules an alarm to go off at (or soon after) time \a when. When 285 Schedules an alarm to go off at (or soon after) time \a when. When
286 the alarm goes off, the \link qcop.html QCop\endlink \a message will 286 the alarm goes off, the \link qcop.html QCop\endlink \a message will
287 be sent to \a channel, with \a data as a parameter. 287 be sent to \a channel, with \a data as a parameter.
288 288
289 If this function is called with exactly the same data as a previous 289 If this function is called with exactly the same data as a previous
290 call the subsequent call is ignored, so there is only ever one alarm 290 call the subsequent call is ignored, so there is only ever one alarm
291 with a given set of parameters. 291 with a given set of parameters.
292 292
293 \sa deleteAlarm() 293 \sa deleteAlarm()
294*/ 294*/
295void AlarmServer::addAlarm ( QDateTime when, const QCString& channel, 295void AlarmServer::addAlarm ( QDateTime when, const QCString& channel,
296 const QCString& message, int data) 296 const QCString& message, int data)
297{ 297{
298 if ( qApp->type() == QApplication::GuiServer ) { 298 if ( qApp->type() == QApplication::GuiServer ) {
299 bool needSave = FALSE; 299 bool needSave = FALSE;
300 // Here we are the server so either it has been directly called from 300 // Here we are the server so either it has been directly called from
301 // within the server or it has been sent to us from a client via QCop 301 // within the server or it has been sent to us from a client via QCop
302 if (!timerEventReceiver) 302 if (!timerEventReceiver)
303 timerEventReceiver = new TimerReceiverObject; 303 timerEventReceiver = new TimerReceiverObject;
304 304
305 timerEventItem *newTimerEventItem = new timerEventItem; 305 timerEventItem *newTimerEventItem = new timerEventItem;
306 newTimerEventItem->UTCtime = TimeConversion::toUTC( when ); 306 newTimerEventItem->UTCtime = TimeConversion::toUTC( when );
307 newTimerEventItem->channel = channel; 307 newTimerEventItem->channel = channel;
308 newTimerEventItem->message = message; 308 newTimerEventItem->message = message;
309 newTimerEventItem->data = data; 309 newTimerEventItem->data = data;
310 // explore the case of already having the event in here... 310 // explore the case of already having the event in here...
311 QListIterator<timerEventItem> it( timerEventList ); 311 QListIterator<timerEventItem> it( timerEventList );
312 for ( ; *it; ++it ) 312 for ( ; *it; ++it )
313 if ( *(*it) == *newTimerEventItem ) 313 if ( *(*it) == *newTimerEventItem )
314 return; 314 return;
315 // if we made it here, it is okay to add the item... 315 // if we made it here, it is okay to add the item...
316 timerEventList.append( newTimerEventItem ); 316 timerEventList.append( newTimerEventItem );
317 needSave = TRUE; 317 needSave = TRUE;
318 // quicker than using setNearestTimerEvent() 318 // quicker than using setNearestTimerEvent()
319 if ( nearestTimerEvent ) { 319 if ( nearestTimerEvent ) {
320 if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) { 320 if (newTimerEventItem->UTCtime < nearestTimerEvent->UTCtime) {
321 nearestTimerEvent = newTimerEventItem; 321 nearestTimerEvent = newTimerEventItem;
322 timerEventReceiver->killTimers(); 322 timerEventReceiver->killTimers();
323 timerEventReceiver->resetTimer(); 323 timerEventReceiver->resetTimer();
324 } 324 }
325 } else { 325 } else {
326 nearestTimerEvent = newTimerEventItem; 326 nearestTimerEvent = newTimerEventItem;
327 timerEventReceiver->resetTimer(); 327 timerEventReceiver->resetTimer();
328 } 328 }
329 if ( needSave ) 329 if ( needSave )
330 saveState(); 330 saveState();
331 } else { 331 } else {
332#ifndef QT_NO_COP 332#ifndef QT_NO_COP
333 QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" ); 333 QCopEnvelope e( "QPE/System", "addAlarm(QDateTime,QCString,QCString,int)" );
334 e << when << channel << message << data; 334 e << when << channel << message << data;
335#endif 335#endif
336 } 336 }
337} 337}
338 338
339/*! 339/*!
340 Deletes previously scheduled alarms which match \a when, \a channel, 340 Deletes previously scheduled alarms which match \a when, \a channel,
341 \a message, and \a data. 341 \a message, and \a data.
342 342
343 Passing null values for \a when, \a channel, or for the \link 343 Passing null values for \a when, \a channel, or for the \link
344 qcop.html QCop\endlink \a message, acts as a wildcard meaning "any". 344 qcop.html QCop\endlink \a message, acts as a wildcard meaning "any".
345 Similarly, passing -1 for \a data indicates "any". 345 Similarly, passing -1 for \a data indicates "any".
346 346
347 If there is no matching alarm, nothing happens. 347 If there is no matching alarm, nothing happens.
348 348
349 \sa addAlarm() 349 \sa addAlarm()
350 350
351*/ 351*/
352void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data) 352void AlarmServer::deleteAlarm (QDateTime when, const QCString& channel, const QCString& message, int data)
353{ 353{
354 if ( qApp->type() == QApplication::GuiServer) { 354 if ( qApp->type() == QApplication::GuiServer) {
355 bool needSave = FALSE; 355 bool needSave = FALSE;
356 if ( timerEventReceiver != NULL ) { 356 if ( timerEventReceiver != NULL ) {
357 timerEventReceiver->killTimers(); 357 timerEventReceiver->killTimers();
358 358
359 // iterate over the list of events 359 // iterate over the list of events
360 QListIterator<timerEventItem> it( timerEventList ); 360 QListIterator<timerEventItem> it( timerEventList );
361 time_t deleteTime = TimeConversion::toUTC( when ); 361 time_t deleteTime = TimeConversion::toUTC( when );
362 for ( ; *it; ++it ) { 362 for ( ; *it; ++it ) {
363 // if its a match, delete it 363 // if its a match, delete it
364 if ( ( (*it)->UTCtime == deleteTime || when.isNull() ) 364 if ( ( (*it)->UTCtime == deleteTime || when.isNull() )
365 && ( channel.isNull() || (*it)->channel == channel ) 365 && ( channel.isNull() || (*it)->channel == channel )
366 && ( message.isNull() || (*it)->message == message ) 366 && ( message.isNull() || (*it)->message == message )
367 && ( data==-1 || (*it)->data == data ) ) 367 && ( data==-1 || (*it)->data == data ) )
368 { 368 {
369 // if it's first, then we need to update the timer 369 // if it's first, then we need to update the timer
370 if ( (*it) == nearestTimerEvent ) { 370 if ( (*it) == nearestTimerEvent ) {
371 timerEventList.remove(*it); 371 timerEventList.remove(*it);
372 setNearestTimerEvent(); 372 setNearestTimerEvent();
373 } else { 373 } else {
374 timerEventList.remove(*it); 374 timerEventList.remove(*it);
375 } 375 }
376 needSave = TRUE; 376 needSave = TRUE;
377 } 377 }
378 } 378 }
379 if ( nearestTimerEvent ) 379 if ( nearestTimerEvent )
380 timerEventReceiver->resetTimer(); 380 timerEventReceiver->resetTimer();
381 } 381 }
382 if ( needSave ) 382 if ( needSave )
383 saveState(); 383 saveState();
384 } else { 384 } else {
385#ifndef QT_NO_COP 385#ifndef QT_NO_COP
386 QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" ); 386 QCopEnvelope e( "QPE/System", "deleteAlarm(QDateTime,QCString,QCString,int)" );
387 e << when << channel << message << data; 387 e << when << channel << message << data;
388#endif 388#endif
389 } 389 }
390} 390}
391 391
392/*! 392/*!
393 Writes the system clock to the hardware clock. 393 Writes the system clock to the hardware clock.
394*/ 394*/
395void Global::writeHWClock() 395void Global::writeHWClock()
396{ 396{
397 if ( !triggerAtd( TRUE ) ) { 397 if ( !triggerAtd( TRUE ) ) {
398 // atd not running? set it ourselves 398 // atd not running? set it ourselves
399 system("/sbin/hwclock --systohc"); // ##### UTC? 399 system("/sbin/hwclock --systohc"); // ##### UTC?
400 } 400 }
401} 401}
diff --git a/library/power.cpp b/library/power.cpp
index d53ecfe..ec5b309 100644
--- a/library/power.cpp
+++ b/library/power.cpp
@@ -1,228 +1,228 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "power.h" 21#include "power.h"
22 22
23#ifdef QT_QWS_CUSTOM 23#ifdef QT_QWS_SHARP
24#include "custom.h" 24#include "custom.h"
25#endif 25#endif
26 26
27#include <unistd.h> 27#include <unistd.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <stdio.h> 29#include <stdio.h>
30#include <fcntl.h> 30#include <fcntl.h>
31#include <sys/ioctl.h> 31#include <sys/ioctl.h>
32 32
33#ifdef QT_QWS_IPAQ_NO_APM 33#ifdef QT_QWS_IPAQ_NO_APM
34#include <linux/h3600_ts.h> 34#include <linux/h3600_ts.h>
35#endif 35#endif
36 36
37PowerStatusManager *PowerStatusManager::powerManager = 0; 37PowerStatusManager *PowerStatusManager::powerManager = 0;
38PowerStatus *PowerStatusManager::ps = 0; 38PowerStatus *PowerStatusManager::ps = 0;
39 39
40static bool haveProcApm = false; 40static bool haveProcApm = false;
41 41
42PowerStatusManager::PowerStatusManager() 42PowerStatusManager::PowerStatusManager()
43{ 43{
44 powerManager = this; 44 powerManager = this;
45 ps = new PowerStatus; 45 ps = new PowerStatus;
46 FILE *f = fopen("/proc/apm", "r"); 46 FILE *f = fopen("/proc/apm", "r");
47 if ( f ) { 47 if ( f ) {
48 fclose(f); 48 fclose(f);
49 haveProcApm = TRUE; 49 haveProcApm = TRUE;
50 } 50 }
51} 51}
52 52
53const PowerStatus &PowerStatusManager::readStatus() 53const PowerStatus &PowerStatusManager::readStatus()
54{ 54{
55 if ( !powerManager ) 55 if ( !powerManager )
56 (void)new PowerStatusManager; 56 (void)new PowerStatusManager;
57 57
58 powerManager->getStatus(); 58 powerManager->getStatus();
59 59
60 return *ps; 60 return *ps;
61} 61}
62 62
63// Standard /proc/apm reader 63// Standard /proc/apm reader
64bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec ) 64bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec )
65{ 65{
66 bool ok = false; 66 bool ok = false;
67 67
68 ac = 0xff; 68 ac = 0xff;
69 bs = 0xff; 69 bs = 0xff;
70 bf = 0xff; 70 bf = 0xff;
71 pc = -1; 71 pc = -1;
72 sec = -1; 72 sec = -1;
73 73
74 FILE *f = fopen("/proc/apm", "r"); 74 FILE *f = fopen("/proc/apm", "r");
75 if ( f ) { 75 if ( f ) {
76 //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec 76 //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec
77 char u; 77 char u;
78 fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c", 78 fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c",
79 &ac, &bs, &bf, &pc, &sec, &u); 79 &ac, &bs, &bf, &pc, &sec, &u);
80 fclose(f); 80 fclose(f);
81 switch ( u ) { 81 switch ( u ) {
82 case 'm': sec *= 60; 82 case 'm': sec *= 60;
83 case 's': break; // ok 83 case 's': break; // ok
84 default: sec = -1; // unknown 84 default: sec = -1; // unknown
85 } 85 }
86 86
87 // extract data 87 // extract data
88 switch ( bs ) { 88 switch ( bs ) {
89 case 0x00: 89 case 0x00:
90 ps->bs = PowerStatus::High; 90 ps->bs = PowerStatus::High;
91 break; 91 break;
92 case 0x01: 92 case 0x01:
93 ps->bs = PowerStatus::Low; 93 ps->bs = PowerStatus::Low;
94 break; 94 break;
95 case 0x7f: 95 case 0x7f:
96 ps->bs = PowerStatus::VeryLow; 96 ps->bs = PowerStatus::VeryLow;
97 break; 97 break;
98 case 0x02: 98 case 0x02:
99 ps->bs = PowerStatus::Critical; 99 ps->bs = PowerStatus::Critical;
100 break; 100 break;
101 case 0x03: 101 case 0x03:
102 ps->bs = PowerStatus::Charging; 102 ps->bs = PowerStatus::Charging;
103 break; 103 break;
104 case 0x04: 104 case 0x04:
105 case 0xff: // 0xff is Unknown but we map to NotPresent 105 case 0xff: // 0xff is Unknown but we map to NotPresent
106 default: 106 default:
107 ps->bs = PowerStatus::NotPresent; 107 ps->bs = PowerStatus::NotPresent;
108 break; 108 break;
109 } 109 }
110 110
111 switch ( ac ) { 111 switch ( ac ) {
112 case 0x00: 112 case 0x00:
113 ps->ac = PowerStatus::Offline; 113 ps->ac = PowerStatus::Offline;
114 break; 114 break;
115 case 0x01: 115 case 0x01:
116 ps->ac = PowerStatus::Online; 116 ps->ac = PowerStatus::Online;
117 break; 117 break;
118 case 0x02: 118 case 0x02:
119 ps->ac = PowerStatus::Backup; 119 ps->ac = PowerStatus::Backup;
120 break; 120 break;
121 } 121 }
122 122
123 if ( pc > 100 ) 123 if ( pc > 100 )
124 pc = -1; 124 pc = -1;
125 125
126 ps->percentRemain = pc; 126 ps->percentRemain = pc;
127 ps->secsRemain = sec; 127 ps->secsRemain = sec;
128 128
129 ok = true; 129 ok = true;
130 } 130 }
131 131
132 return ok; 132 return ok;
133} 133}
134 134
135#ifdef QT_QWS_CUSTOM 135#ifdef QT_QWS_SHARP
136 136
137void PowerStatusManager::getStatus() 137void PowerStatusManager::getStatus()
138{ 138{
139 int ac, bs, bf, pc, sec; 139 int ac, bs, bf, pc, sec;
140 ps->percentAccurate = TRUE; // not for long... 140 ps->percentAccurate = TRUE; // not for long...
141 141
142 if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) { 142 if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) {
143 // special case 143 // special case
144 if ( bs == 0x7f ) 144 if ( bs == 0x7f )
145 ps->bs = PowerStatus::VeryLow; 145 ps->bs = PowerStatus::VeryLow;
146 pc = -1; // fake percentage 146 pc = -1; // fake percentage
147 if ( pc < 0 ) { 147 if ( pc < 0 ) {
148 switch ( bs ) { 148 switch ( bs ) {
149 case 0x00: ps->percentRemain = 100; break; // High 149 case 0x00: ps->percentRemain = 100; break; // High
150 case 0x01: ps->percentRemain = 30; break; // Low 150 case 0x01: ps->percentRemain = 30; break; // Low
151 case 0x7f: ps->percentRemain = 10; break; // Very Low 151 case 0x7f: ps->percentRemain = 10; break; // Very Low
152 case 0x02: ps->percentRemain = 5; break; // Critical 152 case 0x02: ps->percentRemain = 5; break; // Critical
153 case 0x03: ps->percentRemain = -1; break; // Charging 153 case 0x03: ps->percentRemain = -1; break; // Charging
154 } 154 }
155 ps->percentAccurate = FALSE; 155 ps->percentAccurate = FALSE;
156 } 156 }
157 } 157 }
158 158
159 char *device = "/dev/apm_bios"; 159 char *device = "/dev/apm_bios";
160 int fd = ::open (device, O_WRONLY); 160 int fd = ::open (device, O_WRONLY);
161 if ( fd >= 0 ) { 161 if ( fd >= 0 ) {
162 int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 ); 162 int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 );
163 switch ( bbat_status ) { 163 switch ( bbat_status ) {
164 case 0x00: 164 case 0x00:
165 ps->bbs = PowerStatus::High; 165 ps->bbs = PowerStatus::High;
166 break; 166 break;
167 case 0x01: 167 case 0x01:
168 ps->bbs = PowerStatus::Low; 168 ps->bbs = PowerStatus::Low;
169 break; 169 break;
170 case 0x7f: 170 case 0x7f:
171 ps->bbs = PowerStatus::VeryLow; 171 ps->bbs = PowerStatus::VeryLow;
172 break; 172 break;
173 case 0x02: 173 case 0x02:
174 ps->bbs = PowerStatus::Critical; 174 ps->bbs = PowerStatus::Critical;
175 break; 175 break;
176 case 0x03: 176 case 0x03:
177 ps->bbs = PowerStatus::Charging; 177 ps->bbs = PowerStatus::Charging;
178 break; 178 break;
179 case 0x04: 179 case 0x04:
180 ps->bbs = PowerStatus::NotPresent; 180 ps->bbs = PowerStatus::NotPresent;
181 break; 181 break;
182 } 182 }
183 ::close(fd); 183 ::close(fd);
184 } 184 }
185} 185}
186 186
187#else 187#else
188 188
189void PowerStatusManager::getStatus() 189void PowerStatusManager::getStatus()
190{ 190{
191 bool usedApm = FALSE; 191 bool usedApm = FALSE;
192 192
193 ps->percentAccurate = TRUE; 193 ps->percentAccurate = TRUE;
194 194
195 // Some iPAQ kernel builds don't have APM. If this is not the case we 195 // Some iPAQ kernel builds don't have APM. If this is not the case we
196 // save ourselves an ioctl by testing if /proc/apm exists in the 196 // save ourselves an ioctl by testing if /proc/apm exists in the
197 // constructor and we use /proc/apm instead 197 // constructor and we use /proc/apm instead
198 int ac, bs, bf, pc, sec; 198 int ac, bs, bf, pc, sec;
199 if ( haveProcApm ) 199 if ( haveProcApm )
200 usedApm = getProcApmStatus( ac, bs, bf, pc, sec ); 200 usedApm = getProcApmStatus( ac, bs, bf, pc, sec );
201 201
202 if ( !usedApm ) { 202 if ( !usedApm ) {
203#ifdef QT_QWS_IPAQ_NO_APM 203#ifdef QT_QWS_IPAQ_NO_APM
204 int fd; 204 int fd;
205 int err; 205 int err;
206 struct bat_dev batt_info; 206 struct bat_dev batt_info;
207 207
208 memset(&batt_info, 0, sizeof(batt_info)); 208 memset(&batt_info, 0, sizeof(batt_info));
209 209
210 fd = ::open("/dev/ts",O_RDONLY); 210 fd = ::open("/dev/ts",O_RDONLY);
211 if( fd < 0 ) 211 if( fd < 0 )
212 return; 212 return;
213 213
214 ioctl(fd, GET_BATTERY_STATUS, &batt_info); 214 ioctl(fd, GET_BATTERY_STATUS, &batt_info);
215 ac_status = batt_info.ac_status; 215 ac_status = batt_info.ac_status;
216 ps->percentRemain = ( 425 * batt_info.batt1_voltage ) / 1000 - 298; // from h3600_ts.c 216 ps->percentRemain = ( 425 * batt_info.batt1_voltage ) / 1000 - 298; // from h3600_ts.c
217 ps->secsRemain = -1; // seconds is bogus on iPAQ 217 ps->secsRemain = -1; // seconds is bogus on iPAQ
218 ::close (fd); 218 ::close (fd);
219#else 219#else
220 ps->percentRemain = 100; 220 ps->percentRemain = 100;
221 ps->secsRemain = -1; 221 ps->secsRemain = -1;
222 ps->percentAccurate = FALSE; 222 ps->percentAccurate = FALSE;
223#endif 223#endif
224 } 224 }
225} 225}
226 226
227#endif 227#endif
228 228
diff --git a/library/storage.cpp b/library/storage.cpp
index 937908d..3668d29 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -1,200 +1,200 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> 2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include <qpe/storage.h> 22#include <qpe/storage.h>
23#ifdef QT_QWS_CUSTOM 23#ifdef QT_QWS_SHARP
24#include <qpe/custom.h> 24#include <qpe/custom.h>
25#endif 25#endif
26 26
27#include <qfile.h> 27#include <qfile.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qcopchannel_qws.h> 29#include <qcopchannel_qws.h>
30 30
31#include <stdio.h> 31#include <stdio.h>
32 32
33#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 33#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
34#include <sys/vfs.h> 34#include <sys/vfs.h>
35#include <mntent.h> 35#include <mntent.h>
36#endif 36#endif
37 37
38#include <qstringlist.h> 38#include <qstringlist.h>
39 39
40static bool isCF(const QString& m) 40static bool isCF(const QString& m)
41{ 41{
42 FILE* f = fopen("/var/run/stab", "r"); 42 FILE* f = fopen("/var/run/stab", "r");
43 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 43 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
44 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 44 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
45 if ( f ) { 45 if ( f ) {
46 char line[1024]; 46 char line[1024];
47 char devtype[80]; 47 char devtype[80];
48 char devname[80]; 48 char devname[80];
49 while ( fgets( line, 1024, f ) ) { 49 while ( fgets( line, 1024, f ) ) {
50 // 0 ide ide-cs 0 hda 3 0 50 // 0 ide ide-cs 0 hda 3 0
51 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 51 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
52 { 52 {
53 if ( QString(devtype) == "ide" && m.find(devname)>0 ) { 53 if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
54 fclose(f); 54 fclose(f);
55 return TRUE; 55 return TRUE;
56 } 56 }
57 } 57 }
58 } 58 }
59 fclose(f); 59 fclose(f);
60 } 60 }
61 return FALSE; 61 return FALSE;
62} 62}
63 63
64StorageInfo::StorageInfo( QObject *parent ) 64StorageInfo::StorageInfo( QObject *parent )
65 : QObject( parent ) 65 : QObject( parent )
66{ 66{
67 mFileSystems.setAutoDelete( TRUE ); 67 mFileSystems.setAutoDelete( TRUE );
68 channel = new QCopChannel( "QPE/Card", this ); 68 channel = new QCopChannel( "QPE/Card", this );
69 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 69 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
70 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 70 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
71 update(); 71 update();
72} 72}
73 73
74const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 74const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
75{ 75{
76 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 76 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
77 if ( filename.startsWith( (*i)->path() ) ) 77 if ( filename.startsWith( (*i)->path() ) )
78 return (*i); 78 return (*i);
79 } 79 }
80 return 0; 80 return 0;
81} 81}
82 82
83 83
84void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 84void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
85{ 85{
86 if ( msg == "mtabChanged()" ) 86 if ( msg == "mtabChanged()" )
87 update(); 87 update();
88} 88}
89// cause of the lack of a d pointer we need 89// cause of the lack of a d pointer we need
90// to store informations in a config file :( 90// to store informations in a config file :(
91void StorageInfo::update() 91void StorageInfo::update()
92{ 92{
93 //qDebug("StorageInfo::updating"); 93 //qDebug("StorageInfo::updating");
94#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 94#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
95 struct mntent *me; 95 struct mntent *me;
96 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 96 FILE *mntfp = setmntent( "/etc/mtab", "r" );
97 97
98 QStringList curdisks; 98 QStringList curdisks;
99 QStringList curopts; 99 QStringList curopts;
100 QStringList curfs; 100 QStringList curfs;
101 bool rebuild = FALSE; 101 bool rebuild = FALSE;
102 int n=0; 102 int n=0;
103 if ( mntfp ) { 103 if ( mntfp ) {
104 while ( (me = getmntent( mntfp )) != 0 ) { 104 while ( (me = getmntent( mntfp )) != 0 ) {
105 QString fs = me->mnt_fsname; 105 QString fs = me->mnt_fsname;
106 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" 106 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
107 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" 107 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
108 || fs.left( 14 ) == "/dev/mmc/part1" 108 || fs.left( 14 ) == "/dev/mmc/part1"
109 || fs.left(5)=="tmpfs" ) 109 || fs.left(5)=="tmpfs" )
110 { 110 {
111 n++; 111 n++;
112 curdisks.append(fs); 112 curdisks.append(fs);
113 curopts.append( me->mnt_opts ); 113 curopts.append( me->mnt_opts );
114 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); 114 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts );
115 curfs.append( me->mnt_dir ); 115 curfs.append( me->mnt_dir );
116 bool found = FALSE; 116 bool found = FALSE;
117 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 117 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
118 if ( (*i)->disk() == fs ) { 118 if ( (*i)->disk() == fs ) {
119 found = TRUE; 119 found = TRUE;
120 break; 120 break;
121 } 121 }
122 } 122 }
123 if ( !found ) 123 if ( !found )
124 rebuild = TRUE; 124 rebuild = TRUE;
125 } 125 }
126 } 126 }
127 endmntent( mntfp ); 127 endmntent( mntfp );
128 } 128 }
129 if ( rebuild || n != (int)mFileSystems.count() ) { 129 if ( rebuild || n != (int)mFileSystems.count() ) {
130 mFileSystems.clear(); 130 mFileSystems.clear();
131 QStringList::ConstIterator it=curdisks.begin(); 131 QStringList::ConstIterator it=curdisks.begin();
132 QStringList::ConstIterator fsit=curfs.begin(); 132 QStringList::ConstIterator fsit=curfs.begin();
133 QStringList::ConstIterator optsIt=curopts.begin(); 133 QStringList::ConstIterator optsIt=curopts.begin();
134 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { 134 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) {
135 QString opts = *optsIt; 135 QString opts = *optsIt;
136 136
137 QString disk = *it; 137 QString disk = *it;
138 QString humanname; 138 QString humanname;
139 bool removable = FALSE; 139 bool removable = FALSE;
140 if ( isCF(disk) ) { 140 if ( isCF(disk) ) {
141 humanname = tr("CF Card"); 141 humanname = tr("CF Card");
142 removable = TRUE; 142 removable = TRUE;
143 } else if ( disk == "/dev/hda1" ) { 143 } else if ( disk == "/dev/hda1" ) {
144 humanname = tr("Hard Disk"); 144 humanname = tr("Hard Disk");
145 } else if ( disk.left(9) == "/dev/mmcd" ) { 145 } else if ( disk.left(9) == "/dev/mmcd" ) {
146 humanname = tr("SD Card"); 146 humanname = tr("SD Card");
147 removable = TRUE; 147 removable = TRUE;
148 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) { 148 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) {
149 humanname = tr("MMC Card"); 149 humanname = tr("MMC Card");
150 removable = TRUE; 150 removable = TRUE;
151 } else if ( disk.left(7) == "/dev/hd" ) 151 } else if ( disk.left(7) == "/dev/hd" )
152 humanname = tr("Hard Disk") + " " + disk; 152 humanname = tr("Hard Disk") + " " + disk;
153 else if ( disk.left(7) == "/dev/sd" ) 153 else if ( disk.left(7) == "/dev/sd" )
154 humanname = tr("SCSI Hard Disk") + " " + disk; 154 humanname = tr("SCSI Hard Disk") + " " + disk;
155 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs 155 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs
156 humanname = tr("Internal Memory"); 156 humanname = tr("Internal Memory");
157 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) 157 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
158 humanname = tr("Internal Storage"); 158 humanname = tr("Internal Storage");
159 else if ( disk.left(14) == "/dev/mtdblock/" ) 159 else if ( disk.left(14) == "/dev/mtdblock/" )
160 humanname = tr("Internal Storage") + " " + disk; 160 humanname = tr("Internal Storage") + " " + disk;
161 else if ( disk.left(13) == "/dev/mtdblock" ) 161 else if ( disk.left(13) == "/dev/mtdblock" )
162 humanname = tr("Internal Storage") + " " + disk; 162 humanname = tr("Internal Storage") + " " + disk;
163 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs 163 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs
164 humanname = tr("Internal Memory"); 164 humanname = tr("Internal Memory");
165 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); 165 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts );
166 mFileSystems.append( fs ); 166 mFileSystems.append( fs );
167 } 167 }
168 emit disksChanged(); 168 emit disksChanged();
169 } else { 169 } else {
170 // just update them 170 // just update them
171 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 171 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
172 i.current()->update(); 172 i.current()->update();
173 } 173 }
174#endif 174#endif
175} 175}
176 176
177//--------------------------------------------------------------------------- 177//---------------------------------------------------------------------------
178 178
179FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) 179FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o )
180 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) 180 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o )
181{ 181{
182 update(); 182 update();
183} 183}
184 184
185void FileSystem::update() 185void FileSystem::update()
186{ 186{
187#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 187#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
188 struct statfs fs; 188 struct statfs fs;
189 if ( !statfs( fspath.latin1(), &fs ) ) { 189 if ( !statfs( fspath.latin1(), &fs ) ) {
190 blkSize = fs.f_bsize; 190 blkSize = fs.f_bsize;
191 totalBlks = fs.f_blocks; 191 totalBlks = fs.f_blocks;
192 availBlks = fs.f_bavail; 192 availBlks = fs.f_bavail;
193 } else { 193 } else {
194 blkSize = 0; 194 blkSize = 0;
195 totalBlks = 0; 195 totalBlks = 0;
196 availBlks = 0; 196 availBlks = 0;
197 } 197 }
198#endif 198#endif
199} 199}
200 200
diff --git a/qt/qte233-for-opie091-keyboard.patch b/qt/qte233-for-opie091-keyboard.patch
index 9d76a64..c1b85b6 100644
--- a/qt/qte233-for-opie091-keyboard.patch
+++ b/qt/qte233-for-opie091-keyboard.patch
@@ -1,145 +1,145 @@
1 --- src.orig/kernel/qkeyboard_qws.cppMon Mar 18 02:11:25 2002 1 --- src.orig/kernel/qkeyboard_qws.cppMon Mar 18 02:11:25 2002
2 +++ src/kernel/qkeyboard_qws.cppFri Aug 30 04:28:39 2002 2 +++ src/kernel/qkeyboard_qws.cppFri Aug 30 04:28:39 2002
3@@ -269,7 +269,7 @@ 3@@ -269,7 +269,7 @@
4 { Qt::Key_O, 'o' , 'O' , 'O'-64 }, 4 { Qt::Key_O, 'o' , 'O' , 'O'-64 },
5 { Qt::Key_P, 'p' , 'P' , 'P'-64 }, 5 { Qt::Key_P, 'p' , 'P' , 'P'-64 },
6 { Qt::Key_BraceLeft, '[' , '{' , 0xffff }, 6 { Qt::Key_BraceLeft, '[' , '{' , 0xffff },
7- { Qt::Key_Escape, ']' , '}' , 0xffff }, 7- { Qt::Key_Escape, ']' , '}' , 0xffff },
8+ { Qt::Key_BraceRight, ']' , '}' , 0xffff }, 8+ { Qt::Key_BraceRight, ']' , '}' , 0xffff },
9 { Qt::Key_Return, 13 , 13 , 0xffff }, 9 { Qt::Key_Return, 13 , 13 , 0xffff },
10 { Qt::Key_Control, 0xffff , 0xffff , 0xffff }, 10 { Qt::Key_Control, 0xffff , 0xffff , 0xffff },
11 { Qt::Key_A, 'a' , 'A' , 'A'-64 }, // 30 11 { Qt::Key_A, 'a' , 'A' , 'A'-64 }, // 30
12@@ -394,7 +394,7 @@ 12@@ -394,7 +394,7 @@
13 bool numLock; 13 bool numLock;
14 #endif 14 #endif
15 bool caps; 15 bool caps;
16- bool extended; 16- bool extended;
17+ int extended; 17+ int extended;
18 int modifiers; 18 int modifiers;
19 int prevuni; 19 int prevuni;
20 int prevkey; 20 int prevkey;
21@@ -524,7 +524,7 @@ 21@@ -524,7 +524,7 @@
22 shift = false; 22 shift = false;
23 alt = false; 23 alt = false;
24 ctrl = false; 24 ctrl = false;
25- extended = false; 25- extended = false;
26+ extended = 0; 26+ extended = 0;
27 prevuni = 0; 27 prevuni = 0;
28 prevkey = 0; 28 prevkey = 0;
29 caps = FALSE; 29 caps = FALSE;
30@@ -561,10 +561,24 @@ 30@@ -561,10 +561,24 @@
31 int keyCode = Qt::Key_unknown; 31 int keyCode = Qt::Key_unknown;
32 bool release = false; 32 bool release = false;
33 int keypad = 0; 33 int keypad = 0;
34+#if defined(QT_QWS_IPAQ) 34+#if defined(QT_QWS_IPAQ)
35+ static int ipaq_return_pressed = false; // iPAQ Action Key has ScanCode 0x60: 0x60|0x80 = 0xe0 == extended mode 1 ! 35+ static int ipaq_return_pressed = false; // iPAQ Action Key has ScanCode 0x60: 0x60|0x80 = 0xe0 == extended mode 1 !
36+#endif 36+#endif
37+ 37+
38 #if !defined(QT_QWS_CUSTOM) 38 #if !defined(QT_QWS_SHARP)
39- if (code == 224) { 39- if (code == 224) {
40+ if ((code == 224) 40+ if ((code == 224)
41+#if defined(QT_QWS_IPAQ) 41+#if defined(QT_QWS_IPAQ)
42+ && !ipaq_return_pressed 42+ && !ipaq_return_pressed
43+#endif 43+#endif
44+ ) 44+ )
45+ { 45+ {
46 // extended 46 // extended
47 -extended = true; 47 -extended = true;
48 +extended = 1; 48 +extended = 1;
49 +return; 49 +return;
50+ } 50+ }
51+ else if (code == 225) { 51+ else if (code == 225) {
52 + // extended 2 52 + // extended 2
53 + extended = 2; 53 + extended = 2;
54 return; 54 return;
55 } 55 }
56 #endif 56 #endif
57@@ -574,7 +588,7 @@ 57@@ -574,7 +588,7 @@
58 code &= 0x7f; 58 code &= 0x7f;
59 } 59 }
60 60
61- if (extended) { 61- if (extended) {
62+ if (extended == 1) { 62+ if (extended == 1) {
63 switch (code) { 63 switch (code) {
64 case 72: 64 case 72:
65 keyCode = Qt::Key_Up; 65 keyCode = Qt::Key_Up;
66@@ -612,6 +626,32 @@ 66@@ -612,6 +626,32 @@
67 case 53: 67 case 53:
68 keyCode = Qt::Key_Slash; 68 keyCode = Qt::Key_Slash;
69 break; 69 break;
70 +case 0x1d: 70 +case 0x1d:
71 + keyCode = Qt::Key_Control; 71 + keyCode = Qt::Key_Control;
72 + break; 72 + break;
73 +case 0x2a: 73 +case 0x2a:
74 + keyCode = Qt::Key_SysReq; 74 + keyCode = Qt::Key_SysReq;
75 + break; 75 + break;
76 +case 0x38: 76 +case 0x38:
77 + keyCode = Qt::Key_Alt; 77 + keyCode = Qt::Key_Alt;
78 + break; 78 + break;
79 +case 0x5b: 79 +case 0x5b:
80 + keyCode = Qt::Key_Super_L; 80 + keyCode = Qt::Key_Super_L;
81 + break; 81 + break;
82 +case 0x5c: 82 +case 0x5c:
83 + keyCode = Qt::Key_Super_R; 83 + keyCode = Qt::Key_Super_R;
84 + break; 84 + break;
85 +case 0x5d: 85 +case 0x5d:
86 + keyCode = Qt::Key_Menu; 86 + keyCode = Qt::Key_Menu;
87 + break; 87 + break;
88 +} 88 +}
89+ } else if (extended == 2) { 89+ } else if (extended == 2) {
90 +switch (code) { 90 +switch (code) {
91 +case 0x1d: 91 +case 0x1d:
92 + return; 92 + return;
93 +case 0x45: 93 +case 0x45:
94 + keyCode = Qt::Key_Pause; 94 + keyCode = Qt::Key_Pause;
95 + break; 95 + break;
96 } 96 }
97 } else { 97 } else {
98 #if defined(QT_QWS_CUSTOM) 98 #if defined(QT_QWS_SHARP)
99@@ -650,6 +690,7 @@ 99@@ -650,6 +690,7 @@
100 repeatable = FALSE; 100 repeatable = FALSE;
101 break; 101 break;
102 case 0x60: 102 case 0x60:
103 + ipaq_return_pressed = !release; 103 + ipaq_return_pressed = !release;
104 keyCode = Key_Return; 104 keyCode = Key_Return;
105 break; 105 break;
106 case 0x67: 106 case 0x67:
107@@ -687,13 +728,19 @@ 107@@ -687,13 +728,19 @@
108 else 108 else
109 repeater->stop(); 109 repeater->stop();
110 #endif 110 #endif
111+ 111+
112 +/* 112 +/*
113 + Translate shift+Key_Tab to Key_Backtab 113 + Translate shift+Key_Tab to Key_Backtab
114 +*/ 114 +*/
115 +if (( keyCode == Key_Tab ) && shift ) 115 +if (( keyCode == Key_Tab ) && shift )
116 + keyCode = Key_Backtab; 116 + keyCode = Key_Backtab;
117 } 117 }
118 118
119 /* 119 /*
120 Keypad consists of extended keys 53 and 28, 120 Keypad consists of extended keys 53 and 28,
121 and non-extended keys 55 and 71 through 83. 121 and non-extended keys 55 and 71 through 83.
122 */ 122 */
123- if ( extended ? (code == 53 || code == 28) : 123- if ( extended ? (code == 53 || code == 28) :
124+ if ((extended == 1) ? (code == 53 || code == 28) : 124+ if ((extended == 1) ? (code == 53 || code == 28) :
125 (code == 55 || ( code >= 71 && code <= 83 )) ) 125 (code == 55 || ( code >= 71 && code <= 83 )) )
126 keypad = Qt::Keypad; 126 keypad = Qt::Keypad;
127 127
128@@ -803,7 +850,7 @@ 128@@ -803,7 +850,7 @@
129 unicode = QWSServer::keyMap()[code].shift_unicode ? QWSServer::keyMap()[code].shift_unicode : 0xffff; 129 unicode = QWSServer::keyMap()[code].shift_unicode ? QWSServer::keyMap()[code].shift_unicode : 0xffff;
130 else 130 else
131 unicode = QWSServer::keyMap()[code].unicode ? QWSServer::keyMap()[code].unicode : 0xffff; 131 unicode = QWSServer::keyMap()[code].unicode ? QWSServer::keyMap()[code].unicode : 0xffff;
132 - } else { 132 - } else {
133 + } else if (extended == 1) { 133 + } else if (extended == 1) {
134 if ( code == 53 ) 134 if ( code == 53 )
135 unicode = '/'; 135 unicode = '/';
136 } 136 }
137@@ -829,7 +876,7 @@ 137@@ -829,7 +876,7 @@
138 prevkey = prevuni = 0; 138 prevkey = prevuni = 0;
139 } 139 }
140 } 140 }
141- extended = false; 141- extended = false;
142+ extended = 0; 142+ extended = 0;
143 } 143 }
144 144
145 145