summaryrefslogtreecommitdiff
path: root/noncore/comm
Unidiff
Diffstat (limited to 'noncore/comm') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/comm/keypebble/.cvsignore5
-rw-r--r--noncore/comm/keypebble/LICENSE.GPL286
-rw-r--r--noncore/comm/keypebble/Makefile.in286
-rw-r--r--noncore/comm/keypebble/README.html206
-rw-r--r--noncore/comm/keypebble/d3des.c439
-rw-r--r--noncore/comm/keypebble/d3des.h50
-rw-r--r--noncore/comm/keypebble/keypebble.pro38
-rw-r--r--noncore/comm/keypebble/krfbbuffer.cpp163
-rw-r--r--noncore/comm/keypebble/krfbbuffer.h62
-rw-r--r--noncore/comm/keypebble/krfbcanvas.cpp169
-rw-r--r--noncore/comm/keypebble/krfbcanvas.h54
-rw-r--r--noncore/comm/keypebble/krfbconnection.cpp242
-rw-r--r--noncore/comm/keypebble/krfbconnection.h152
-rw-r--r--noncore/comm/keypebble/krfbdecoder.cpp839
-rw-r--r--noncore/comm/keypebble/krfbdecoder.h134
-rw-r--r--noncore/comm/keypebble/krfblogin.cpp255
-rw-r--r--noncore/comm/keypebble/krfblogin.h62
-rw-r--r--noncore/comm/keypebble/krfboptions.cpp52
-rw-r--r--noncore/comm/keypebble/krfboptions.h31
-rw-r--r--noncore/comm/keypebble/krfbserverinfo.h42
-rw-r--r--noncore/comm/keypebble/kvnc.cpp191
-rw-r--r--noncore/comm/keypebble/kvnc.h56
-rw-r--r--noncore/comm/keypebble/kvncconnectdlg.cpp79
-rw-r--r--noncore/comm/keypebble/kvncconnectdlg.h39
-rw-r--r--noncore/comm/keypebble/kvncoptionsdlg.cpp53
-rw-r--r--noncore/comm/keypebble/kvncoptionsdlg.h30
-rw-r--r--noncore/comm/keypebble/main.cpp18
-rw-r--r--noncore/comm/keypebble/qpe-keypebble.control10
-rw-r--r--noncore/comm/keypebble/vncauth.c160
-rw-r--r--noncore/comm/keypebble/vncauth.h30
-rw-r--r--noncore/comm/keypebble/vncoptionsbase.ui270
31 files changed, 4503 insertions, 0 deletions
diff --git a/noncore/comm/keypebble/.cvsignore b/noncore/comm/keypebble/.cvsignore
new file mode 100644
index 0000000..c4782a1
--- a/dev/null
+++ b/noncore/comm/keypebble/.cvsignore
@@ -0,0 +1,5 @@
1moc_*
2*.moc
3Makefile
4vncoptionsbase.cpp
5vncoptionsbase.h
diff --git a/noncore/comm/keypebble/LICENSE.GPL b/noncore/comm/keypebble/LICENSE.GPL
new file mode 100644
index 0000000..ec5dad8
--- a/dev/null
+++ b/noncore/comm/keypebble/LICENSE.GPL
@@ -0,0 +1,286 @@
1NOTE! The GPL below is copyrighted by the Free Software Foundation, but
2the instance of code that it refers to (the kde programs) are copyrighted
3by the authors who actually wrote it.
4
5---------------------------------------------------------------------------
6
7 GNU GENERAL PUBLIC LICENSE
8 Version 2, June 1991
9
10 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
11 675 Mass Ave, Cambridge, MA 02139, USA
12 Everyone is permitted to copy and distribute verbatim copies
13 of this license document, but changing it is not allowed.
14
15 Preamble
16
17 The licenses for most software are designed to take away your
18freedom to share and change it. By contrast, the GNU General Public
19License is intended to guarantee your freedom to share and change free
20software--to make sure the software is free for all its users. This
21General Public License applies to most of the Free Software
22Foundation's software and to any other program whose authors commit to
23using it. (Some other Free Software Foundation software is covered by
24the GNU Library General Public License instead.) You can apply it to
25your programs, too.
26
27 When we speak of free software, we are referring to freedom, not
28price. Our General Public Licenses are designed to make sure that you
29have the freedom to distribute copies of free software (and charge for
30this service if you wish), that you receive source code or can get it
31if you want it, that you can change the software or use pieces of it
32in new free programs; and that you know you can do these things.
33
34 To protect your rights, we need to make restrictions that forbid
35anyone to deny you these rights or to ask you to surrender the rights.
36These restrictions translate to certain responsibilities for you if you
37distribute copies of the software, or if you modify it.
38
39 For example, if you distribute copies of such a program, whether
40gratis or for a fee, you must give the recipients all the rights that
41you have. You must make sure that they, too, receive or can get the
42source code. And you must show them these terms so they know their
43rights.
44
45 We protect your rights with two steps: (1) copyright the software, and
46(2) offer you this license which gives you legal permission to copy,
47distribute and/or modify the software.
48
49 Also, for each author's protection and ours, we want to make certain
50that everyone understands that there is no warranty for this free
51software. If the software is modified by someone else and passed on, we
52want its recipients to know that what they have is not the original, so
53that any problems introduced by others will not reflect on the original
54authors' reputations.
55
56 Finally, any free program is threatened constantly by software
57patents. We wish to avoid the danger that redistributors of a free
58program will individually obtain patent licenses, in effect making the
59program proprietary. To prevent this, we have made it clear that any
60patent must be licensed for everyone's free use or not licensed at all.
61
62 The precise terms and conditions for copying, distribution and
63modification follow.
64
65 GNU GENERAL PUBLIC LICENSE
66 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
67
68 0. This License applies to any program or other work which contains
69a notice placed by the copyright holder saying it may be distributed
70under the terms of this General Public License. The "Program", below,
71refers to any such program or work, and a "work based on the Program"
72means either the Program or any derivative work under copyright law:
73that is to say, a work containing the Program or a portion of it,
74either verbatim or with modifications and/or translated into another
75language. (Hereinafter, translation is included without limitation in
76the term "modification".) Each licensee is addressed as "you".
77
78Activities other than copying, distribution and modification are not
79covered by this License; they are outside its scope. The act of
80running the Program is not restricted, and the output from the Program
81is covered only if its contents constitute a work based on the
82Program (independent of having been made by running the Program).
83Whether that is true depends on what the Program does.
84
85 1. You may copy and distribute verbatim copies of the Program's
86source code as you receive it, in any medium, provided that you
87conspicuously and appropriately publish on each copy an appropriate
88copyright notice and disclaimer of warranty; keep intact all the
89notices that refer to this License and to the absence of any warranty;
90and give any other recipients of the Program a copy of this License
91along with the Program.
92
93You may charge a fee for the physical act of transferring a copy, and
94you may at your option offer warranty protection in exchange for a fee.
95
96 2. You may modify your copy or copies of the Program or any portion
97of it, thus forming a work based on the Program, and copy and
98distribute such modifications or work under the terms of Section 1
99above, provided that you also meet all of these conditions:
100
101 a) You must cause the modified files to carry prominent notices
102 stating that you changed the files and the date of any change.
103
104 b) You must cause any work that you distribute or publish, that in
105 whole or in part contains or is derived from the Program or any
106 part thereof, to be licensed as a whole at no charge to all third
107 parties under the terms of this License.
108
109 c) If the modified program normally reads commands interactively
110 when run, you must cause it, when started running for such
111 interactive use in the most ordinary way, to print or display an
112 announcement including an appropriate copyright notice and a
113 notice that there is no warranty (or else, saying that you provide
114 a warranty) and that users may redistribute the program under
115 these conditions, and telling the user how to view a copy of this
116 License. (Exception: if the Program itself is interactive but
117 does not normally print such an announcement, your work based on
118 the Program is not required to print an announcement.)
119
120These requirements apply to the modified work as a whole. If
121identifiable sections of that work are not derived from the Program,
122and can be reasonably considered independent and separate works in
123themselves, then this License, and its terms, do not apply to those
124sections when you distribute them as separate works. But when you
125distribute the same sections as part of a whole which is a work based
126on the Program, the distribution of the whole must be on the terms of
127this License, whose permissions for other licensees extend to the
128entire whole, and thus to each and every part regardless of who wrote it.
129
130Thus, it is not the intent of this section to claim rights or contest
131your rights to work written entirely by you; rather, the intent is to
132exercise the right to control the distribution of derivative or
133collective works based on the Program.
134
135In addition, mere aggregation of another work not based on the Program
136with the Program (or with a work based on the Program) on a volume of
137a storage or distribution medium does not bring the other work under
138the scope of this License.
139
140 3. You may copy and distribute the Program (or a work based on it,
141under Section 2) in object code or executable form under the terms of
142Sections 1 and 2 above provided that you also do one of the following:
143
144 a) Accompany it with the complete corresponding machine-readable
145 source code, which must be distributed under the terms of Sections
146 1 and 2 above on a medium customarily used for software interchange; or,
147
148 b) Accompany it with a written offer, valid for at least three
149 years, to give any third party, for a charge no more than your
150 cost of physically performing source distribution, a complete
151 machine-readable copy of the corresponding source code, to be
152 distributed under the terms of Sections 1 and 2 above on a medium
153 customarily used for software interchange; or,
154
155 c) Accompany it with the information you received as to the offer
156 to distribute corresponding source code. (This alternative is
157 allowed only for noncommercial distribution and only if you
158 received the program in object code or executable form with such
159 an offer, in accord with Subsection b above.)
160
161The source code for a work means the preferred form of the work for
162making modifications to it. For an executable work, complete source
163code means all the source code for all modules it contains, plus any
164associated interface definition files, plus the scripts used to
165control compilation and installation of the executable. However, as a
166special exception, the source code distributed need not include
167anything that is normally distributed (in either source or binary
168form) with the major components (compiler, kernel, and so on) of the
169operating system on which the executable runs, unless that component
170itself accompanies the executable.
171
172If distribution of executable or object code is made by offering
173access to copy from a designated place, then offering equivalent
174access to copy the source code from the same place counts as
175distribution of the source code, even though third parties are not
176compelled to copy the source along with the object code.
177
178 4. You may not copy, modify, sublicense, or distribute the Program
179except as expressly provided under this License. Any attempt
180otherwise to copy, modify, sublicense or distribute the Program is
181void, and will automatically terminate your rights under this License.
182However, parties who have received copies, or rights, from you under
183this License will not have their licenses terminated so long as such
184parties remain in full compliance.
185
186 5. You are not required to accept this License, since you have not
187signed it. However, nothing else grants you permission to modify or
188distribute the Program or its derivative works. These actions are
189prohibited by law if you do not accept this License. Therefore, by
190modifying or distributing the Program (or any work based on the
191Program), you indicate your acceptance of this License to do so, and
192all its terms and conditions for copying, distributing or modifying
193the Program or works based on it.
194
195 6. Each time you redistribute the Program (or any work based on the
196Program), the recipient automatically receives a license from the
197original licensor to copy, distribute or modify the Program subject to
198these terms and conditions. You may not impose any further
199restrictions on the recipients' exercise of the rights granted herein.
200You are not responsible for enforcing compliance by third parties to
201this License.
202
203 7. If, as a consequence of a court judgment or allegation of patent
204infringement or for any other reason (not limited to patent issues),
205conditions are imposed on you (whether by court order, agreement or
206otherwise) that contradict the conditions of this License, they do not
207excuse you from the conditions of this License. If you cannot
208distribute so as to satisfy simultaneously your obligations under this
209License and any other pertinent obligations, then as a consequence you
210may not distribute the Program at all. For example, if a patent
211license would not permit royalty-free redistribution of the Program by
212all those who receive copies directly or indirectly through you, then
213the only way you could satisfy both it and this License would be to
214refrain entirely from distribution of the Program.
215
216If any portion of this section is held invalid or unenforceable under
217any particular circumstance, the balance of the section is intended to
218apply and the section as a whole is intended to apply in other
219circumstances.
220
221It is not the purpose of this section to induce you to infringe any
222patents or other property right claims or to contest validity of any
223such claims; this section has the sole purpose of protecting the
224integrity of the free software distribution system, which is
225implemented by public license practices. Many people have made
226generous contributions to the wide range of software distributed
227through that system in reliance on consistent application of that
228system; it is up to the author/donor to decide if he or she is willing
229to distribute software through any other system and a licensee cannot
230impose that choice.
231
232This section is intended to make thoroughly clear what is believed to
233be a consequence of the rest of this License.
234
235 8. If the distribution and/or use of the Program is restricted in
236certain countries either by patents or by copyrighted interfaces, the
237original copyright holder who places the Program under this License
238may add an explicit geographical distribution limitation excluding
239those countries, so that distribution is permitted only in or among
240countries not thus excluded. In such case, this License incorporates
241the limitation as if written in the body of this License.
242
243 9. The Free Software Foundation may publish revised and/or new versions
244of the General Public License from time to time. Such new versions will
245be similar in spirit to the present version, but may differ in detail to
246address new problems or concerns.
247
248Each version is given a distinguishing version number. If the Program
249specifies a version number of this License which applies to it and "any
250later version", you have the option of following the terms and conditions
251either of that version or of any later version published by the Free
252Software Foundation. If the Program does not specify a version number of
253this License, you may choose any version ever published by the Free Software
254Foundation.
255
256 10. If you wish to incorporate parts of the Program into other free
257programs whose distribution conditions are different, write to the author
258to ask for permission. For software which is copyrighted by the Free
259Software Foundation, write to the Free Software Foundation; we sometimes
260make exceptions for this. Our decision will be guided by the two goals
261of preserving the free status of all derivatives of our free software and
262of promoting the sharing and reuse of software generally.
263
264 NO WARRANTY
265
266 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
267FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
268OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
269PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
270OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
271MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
272TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
273PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
274REPAIR OR CORRECTION.
275
276 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
277WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
278REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
279INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
280OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
281TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
282YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
283PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
284POSSIBILITY OF SUCH DAMAGES.
285
286 END OF TERMS AND CONDITIONS
diff --git a/noncore/comm/keypebble/Makefile.in b/noncore/comm/keypebble/Makefile.in
new file mode 100644
index 0000000..1dbd5d2
--- a/dev/null
+++ b/noncore/comm/keypebble/Makefile.in
@@ -0,0 +1,286 @@
1#############################################################################
2
3####### Compiler, tools and options
4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS)
9 INCPATH =-I$(QPEDIR)/include
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC)
14
15####### Target
16
17DESTDIR = ../bin/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= keypebble
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =d3des.h \
27 krfbbuffer.h \
28 krfbcanvas.h \
29 krfbconnection.h \
30 krfbdecoder.h \
31 krfblogin.h \
32 krfboptions.h \
33 krfbserverinfo.h \
34 kvnc.h \
35 kvncconnectdlg.h \
36 kvncoptionsdlg.h \
37 version.h \
38 vncauth.h
39 SOURCES =d3des.c \
40 vncauth.c \
41 krfbbuffer.cpp \
42 krfbcanvas.cpp \
43 krfbconnection.cpp \
44 krfbdecoder.cpp \
45 krfblogin.cpp \
46 krfboptions.cpp \
47 kvnc.cpp \
48 kvncconnectdlg.cpp \
49 kvncoptionsdlg.cpp \
50 main.cpp
51 OBJECTS =d3des.o \
52 vncauth.o \
53 krfbbuffer.o \
54 krfbcanvas.o \
55 krfbconnection.o \
56 krfbdecoder.o \
57 krfblogin.o \
58 krfboptions.o \
59 kvnc.o \
60 kvncconnectdlg.o \
61 kvncoptionsdlg.o \
62 main.o \
63 vncoptionsbase.o
64INTERFACES = vncoptionsbase.ui
65UICDECLS = vncoptionsbase.h
66UICIMPLS = vncoptionsbase.cpp
67 SRCMOC =moc_krfbbuffer.cpp \
68 moc_krfbcanvas.cpp \
69 moc_krfbconnection.cpp \
70 moc_krfbdecoder.cpp \
71 moc_krfblogin.cpp \
72 moc_kvnc.cpp \
73 moc_kvncconnectdlg.cpp \
74 moc_kvncoptionsdlg.cpp \
75 moc_vncoptionsbase.cpp
76 OBJMOC =moc_krfbbuffer.o \
77 moc_krfbcanvas.o \
78 moc_krfbconnection.o \
79 moc_krfbdecoder.o \
80 moc_krfblogin.o \
81 moc_kvnc.o \
82 moc_kvncconnectdlg.o \
83 moc_kvncoptionsdlg.o \
84 moc_vncoptionsbase.o
85
86
87####### Implicit rules
88
89.SUFFIXES: .cpp .cxx .cc .C .c
90
91.cpp.o:
92 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
93
94.cxx.o:
95 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
96
97.cc.o:
98 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
99
100.C.o:
101 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
102
103.c.o:
104 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
105
106####### Build rules
107
108
109all: $(DESTDIR)$(TARGET)
110
111$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
112 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
113
114moc: $(SRCMOC)
115
116tmake:
117 tmake keypebble.pro
118
119clean:
120 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
121 -rm -f *~ core
122 -rm -f allmoc.cpp
123
124####### Extension Modules
125
126listpromodules:
127 @echo
128
129listallmodules:
130 @echo
131
132listaddonpromodules:
133 @echo
134
135listaddonentmodules:
136 @echo
137
138
139REQUIRES=
140
141####### Sub-libraries
142
143
144###### Combined headers
145
146
147
148####### Compile
149
150d3des.o: d3des.c \
151 d3des.h
152
153vncauth.o: vncauth.c \
154 vncauth.h \
155 d3des.h
156
157krfbbuffer.o: krfbbuffer.cpp \
158 krfbdecoder.h \
159 krfbbuffer.h \
160 krfbserverinfo.h
161
162krfbcanvas.o: krfbcanvas.cpp \
163 kvncconnectdlg.h \
164 krfbconnection.h \
165 krfbcanvas.h \
166 krfboptions.h \
167 krfbbuffer.h \
168 $(QPEDIR)/include/qpe/config.h
169
170krfbconnection.o: krfbconnection.cpp \
171 krfbconnection.h \
172 krfblogin.h \
173 krfboptions.h \
174 krfbdecoder.h \
175 krfbbuffer.h
176
177krfbdecoder.o: krfbdecoder.cpp \
178 krfbconnection.h \
179 krfboptions.h \
180 krfbserverinfo.h \
181 krfbdecoder.h \
182 krfbbuffer.h \
183 $(QPEDIR)/include/qpe/qpeapplication.h
184
185krfblogin.o: krfblogin.cpp \
186 vncauth.h \
187 krfblogin.h \
188 krfbconnection.h
189
190krfboptions.o: krfboptions.cpp \
191 $(QPEDIR)/include/qpe/config.h \
192 $(QPEDIR)/include/qpe/qpeapplication.h \
193 krfboptions.h
194
195kvnc.o: kvnc.cpp \
196 $(QPEDIR)/include/qpe/qpemenubar.h \
197 $(QPEDIR)/include/qpe/qpetoolbar.h \
198 $(QPEDIR)/include/qpe/qpeapplication.h \
199 $(QPEDIR)/include/qpe/global.h \
200 kvnc.h \
201 krfbcanvas.h \
202 kvncoptionsdlg.h \
203 vncoptionsbase.h \
204 krfbconnection.h
205
206kvncconnectdlg.o: kvncconnectdlg.cpp \
207 krfbconnection.h \
208 kvncoptionsdlg.h \
209 vncoptionsbase.h \
210 kvncconnectdlg.h
211
212kvncoptionsdlg.o: kvncoptionsdlg.cpp \
213 krfboptions.h \
214 kvncoptionsdlg.h \
215 vncoptionsbase.h
216
217main.o: main.cpp \
218 $(QPEDIR)/include/qpe/qpeapplication.h \
219 kvnc.h
220
221vncoptionsbase.h: vncoptionsbase.ui
222 $(UIC) vncoptionsbase.ui -o $(INTERFACE_DECL_PATH)/vncoptionsbase.h
223
224vncoptionsbase.cpp: vncoptionsbase.ui
225 $(UIC) vncoptionsbase.ui -i vncoptionsbase.h -o vncoptionsbase.cpp
226
227vncoptionsbase.o: vncoptionsbase.cpp \
228 vncoptionsbase.h \
229 vncoptionsbase.ui
230
231moc_krfbbuffer.o: moc_krfbbuffer.cpp \
232 krfbbuffer.h
233
234moc_krfbcanvas.o: moc_krfbcanvas.cpp \
235 krfbcanvas.h
236
237moc_krfbconnection.o: moc_krfbconnection.cpp \
238 krfbconnection.h
239
240moc_krfbdecoder.o: moc_krfbdecoder.cpp \
241 krfbdecoder.h
242
243moc_krfblogin.o: moc_krfblogin.cpp \
244 krfblogin.h
245
246moc_kvnc.o: moc_kvnc.cpp \
247 kvnc.h
248
249moc_kvncconnectdlg.o: moc_kvncconnectdlg.cpp \
250 kvncconnectdlg.h
251
252moc_kvncoptionsdlg.o: moc_kvncoptionsdlg.cpp \
253 kvncoptionsdlg.h \
254 vncoptionsbase.h
255
256moc_vncoptionsbase.o: moc_vncoptionsbase.cpp \
257 vncoptionsbase.h
258
259moc_krfbbuffer.cpp: krfbbuffer.h
260 $(MOC) krfbbuffer.h -o moc_krfbbuffer.cpp
261
262moc_krfbcanvas.cpp: krfbcanvas.h
263 $(MOC) krfbcanvas.h -o moc_krfbcanvas.cpp
264
265moc_krfbconnection.cpp: krfbconnection.h
266 $(MOC) krfbconnection.h -o moc_krfbconnection.cpp
267
268moc_krfbdecoder.cpp: krfbdecoder.h
269 $(MOC) krfbdecoder.h -o moc_krfbdecoder.cpp
270
271moc_krfblogin.cpp: krfblogin.h
272 $(MOC) krfblogin.h -o moc_krfblogin.cpp
273
274moc_kvnc.cpp: kvnc.h
275 $(MOC) kvnc.h -o moc_kvnc.cpp
276
277moc_kvncconnectdlg.cpp: kvncconnectdlg.h
278 $(MOC) kvncconnectdlg.h -o moc_kvncconnectdlg.cpp
279
280moc_kvncoptionsdlg.cpp: kvncoptionsdlg.h
281 $(MOC) kvncoptionsdlg.h -o moc_kvncoptionsdlg.cpp
282
283moc_vncoptionsbase.cpp: vncoptionsbase.h
284 $(MOC) vncoptionsbase.h -o moc_vncoptionsbase.cpp
285
286
diff --git a/noncore/comm/keypebble/README.html b/noncore/comm/keypebble/README.html
new file mode 100644
index 0000000..def766b
--- a/dev/null
+++ b/noncore/comm/keypebble/README.html
@@ -0,0 +1,206 @@
1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3 <head>
4 <title>Keystone README</title>
5 </head>
6
7 <body>
8 <h1>Keystone README</h1>
9 <div align="justify"> <!-- #BeginEditable "Body" -->
10 <h3>Contents</h3>
11 <ul>
12 <li><a href="#whatisvnc">What is Keystone?</a></li>
13 <li><a href="#servers">Servers</a></li>
14 <li><a href="#status">Status</a></li>
15 <li><a href="#bugs">Bugs</a></li>
16 <li><a href="#download">Download</a></li>
17 <li><a href="#faq">FAQs</a></li>
18 <li><a href="#todo">Todo</a></li>
19 <li><a href="#credits">Credits</a></li>
20 <li><a href="#references">References</a></li>
21 </ul>
22 <h3><a name="whatiskvnc">What is Keystone?</a></h3>
23 <p>Keystone is a tool for <a href="http://www.kde.org/">KDE</a> that
24 allows you to remotely access the desktops of machines using the cross-platform
25 VNC system. Keystone can access machines running a variety of operating
26 systems (including most UNIX systems and Windows 95/98/NT/2000) providing
27 they are running a VNC server. Note that Keystone is only a client
28 program, you will need to download a server separately in order to
29 use it.</p>
30 <p>The protocol used by Keystone (called RFB) was developed, and released
31 as GPL by ORL (now the UK branch of AT&amp;T research), they also
32 wrote and maintain GPL servers for several platforms. You can find
33 both information about the protocol and links to servers for a range
34 of platforms on their <a href="http://www.uk.research.att.com/vnc/">website</a>.</p>
35 <p>Keystone started life as a port of Markus Wuebben's kvncviewer program
36 to KDE 2, but in the course porting the code, I have rewritten and
37 redesigned most of the system. The new implementation builds on several
38 new facilities that were not available in KDE 1, such as KPixmapIO
39 and QSocket. There is so little of the original code left that I have
40 decided on a name change, and to put the version number back to 0.1.</p>
41 <p>You can see a few screenshots of <a href="http://www.ipso-facto.demon.co.uk/keystone/screenshots.html">Keystone
42 in action</a> on my screenshots page. The screenshots may or may not
43 reflect the look of the current version as I have some look and feel
44 improvements planned.</p>
45 <h3><a name="servers">Servers</a></h3>
46 <p>Most Linux distributions include the standard Xvnc server (usually
47 run via the <i>vncserver</i> script), you can also download this and
48 servers for other platforms such as MS Windows from the <a href="http://www.uk.research.att.com/vnc/">VNC
49 website</a>. If you have a problem with setting up a server then you
50 should read the <a href="http://www.uk.research.att.com/vnc/faq.html">VNC
51 FAQ</a>, and if that does not help join the VNC mailing list. Do not
52 mail me on this topic - I can't help and won't even reply.</p>
53 <p>I may in future write a server that operates in the same manner as
54 the Win32 server for KDE. The Win32 server differs from the X11 server
55 in that it does not virtualise the entire desktop. This has both advantages
56 and disadvatages, it means that you can make an existing session available
57 over the network, but only allows you to run a single server. I may
58 also put a GUI together that makes it easy to configure the ORL server.</p>
59 <h3><a name="status">Status</a></h3>
60 <p><font color="#000000">The current version is 0.4, and the following
61 are now working:</font></p>
62 <p>
63 <ul>
64 <li><b>0.1</b>
65 <ul>
66 <li>Non-blocking socket handling</li>
67 <li>Authentication and logon</li>
68 <li>KDE 2 user interface</li>
69 <li>Raw and CopyRect encodings</li>
70 <li>Full screen mode</li>
71 <li>Grab keyboard mode</li>
72 <li>Graphics</li>
73 <li>Taking screenshots of the remote desktop</li>
74 <li>Event dispatching</li>
75 <li>Konqueror helper application support (you can run Keystone
76 by entering a vnc: URL anywhere in KDE).</li>
77 <li>Options, login, password and about dialogs</li>
78 </ul>
79 </li>
80 <li><b>0.2</b>
81 <ul>
82 <li>XSHM support using KPixmapIO</li>
83 <li>Now uses KXMLGUI (thanks to Kurt)</li>
84 <li>Tru64 patch from Tom Leitner</li>
85 <li>Status reporting improvements</li>
86 <li>Config handling fixed</li>
87 <li>Recent connections list implemented</li>
88 <li>Update frequency respected</li>
89 </ul>
90 </li>
91 <li><b>0.3 [KDE 2.0]</b>
92 <ul>
93 <li>Portability fixes for FreeBSD (and maybe others)</li>
94 </ul>
95 </li>
96 <li><b>0.4</b>
97 <ul>
98 <li>Icons for the full screen mode now reflect the current state</li>
99 <li>Added a toolbar (optional of course)</li>
100 <li>Added support for the clipboard (you can cut and paste between the
101 local and remote machines)</li>
102 <li>Added some what's this help to the options dialog</li>
103 </ul>
104 </li>
105 </ul>
106 <h3><a name="bugs">Bugs</a></h3>
107 <p>Version 0.4 contains the following known bugs:
108 <ul>
109 <li><b>Custom about dialog is not shown</b><br>
110 I can't see a clean way to fix this without creating a complete custom
111 help menu. For now I've left the standard about dialog in place.
112 </li>
113 <li><b>Crash when you connect to a non-existant server</b><br>
114 I can reproduce this every time, but I can't figure out what's wrong
115 other developers have reported similar problems and they seem to be
116 down to QSocket. The only known fix so far is to use KSocket instead.
117 I'd prefer to fix the problem at the source, but I'm having no luck and
118 I suspect QSocket may also be causing some other weird network issues
119 I've seen, so if I can't track down the bug soon I'll give in and switch
120 to KSocket like everyone else.
121 </li>
122 </ul>
123 </p>
124 <h3><a name="download"></a>Download</h3>
125 <p>Keystone is available in the kdenetwork module of the
126 <a href="http://www.kde.org/anoncvs.html">KDE CVS</a>, and
127 is included in the KDE 2.0 release. The current version is 0.4.
128 Note that Keystone <b>requires KDE 2</b>, you cannot use KDE 1.x.</p>
129 <h3><a name="faq"></a>FAQs</h3>
130 <p>
131 <ul>
132 <li><b>Why don't the shortcut keys work in full screen mode?</b><br>
133 When you're in full screen mode Keystone grabs the keyboard to send
134 every key press to the remote screen. This means that you can send key
135 combinations that are used by Keystone or KDE to the remote screen. If
136 you really hate it, then you can add -nograb to the command line
137 arguments to disable all keyboard grabs. I will add an option to allow
138 this behaviour to be overridden in a future release.
139 </li>
140 <li><b>Why is Keystone so slow?</b><br>
141 Currently only the simplest of the RFB encodings are supported, this
142 means that Keystone is only useful on fairly fast networks. This is
143 a serious bug and is being addressed.
144 </ul>
145 </p>
146 <h3><a name="todo">Todo</a></h3>
147 These are the things I'm hoping to add to future versions of Keystone.
148 They're vaguely sorted in order of importance.
149 <p>
150 <ul>
151 <li>RRE encoding.<br>
152 I've started this, but the implementation has some
153 bugs so it did not make the cut for Keystone 0.3.</li>
154 <li>CoRRE and Hextile encodings</li>
155 <li>Session management</li>
156 <li>Support for Windows Terminal Server.<br>
157 There is now a GPL implementation
158 of the protocol, and the author is happy for me to use the code. If someone
159 can offer me an account to test it on then this is possible.</li>
160 <li>Zoom support.<br>
161 This will be handled using the same protocol extension
162 as is used in the Palm client, this will allow you to make use of
163 server side scaling to reduce the amount of network traffic. You
164 will also be able to do client side zooms, but in this case the
165 full screen needs to transmitted over the network.</li>
166 <li>Macros</li>
167 <li>Monitor mode (thumbnails of several machines)</li>
168 <li>ZLib extension support</li>
169 <li>Bookmarks</li>
170 <li>URL specific settings</li>
171 <li>Possibly a DnD extension using a mechanism based on mulitpart
172 MIME attachments.</li>
173 </ul>
174 <h3>Credits<a name="credits"></a></h3>
175 <p>Keystone owes a lot to Markus Wuebben's kvncviewer which some of
176 the code is derived from. Thanks are also due to Espen Sand the author
177 of khexedit from which I borrowed some code for the about dialog.
178 Alison Burch drew the bridge image used in the background of this
179 page (and in future versions of Keystone too of course). Finally thanks
180 go to ORL for making the RFB protocol and servers GPL.</p>
181 <h3><a name="references">References</a><br>
182 </h3>
183 <p>
184 <ul>
185 <li>The Keystone homepage<br>
186 <a href="http://www.ipso-facto.demon.co.uk/keystone/">http://www.ipso-facto.demon.co.uk/keystone/</a></li>
187 <li>The VNC Homepage<br>
188 <a href="http://www.uk.research.att.com/vnc/">http://www.uk.research.att.com/vnc/</a></li>
189 <li>The VNC FAQ<br>
190 <a href="http://www.uk.research.att.com/vnc/faq.html">http://www.uk.research.att.com/vnc/faq.html</a></li>
191 <li>The KDE Homepage<br>
192 <a href="http://www.kde.org/">http://www.kde.org/</a> </li>
193 </ul>
194 <p></p>
195 <!-- #EndEditable --> </div>
196
197
198
199 <hr>
200 <address><a href="mailto:rich@kde.org">Richard Moore</a></address>
201<!-- Created: Tue Dec 5 01:35:56 GMT 2000 -->
202<!-- hhmts start -->
203Last modified: Tue Dec 5 01:37:17 GMT 2000
204<!-- hhmts end -->
205 </body>
206</html>
diff --git a/noncore/comm/keypebble/d3des.c b/noncore/comm/keypebble/d3des.c
new file mode 100644
index 0000000..b0f065e
--- a/dev/null
+++ b/noncore/comm/keypebble/d3des.c
@@ -0,0 +1,439 @@
1/*
2 * This is D3DES (V5.09) by Richard Outerbridge with the double and
3 * triple-length support removed for use in VNC. Also the bytebit[] array
4 * has been reversed so that the most significant bit in each byte of the
5 * key is ignored, not the least significant.
6 *
7 * These changes are Copyright (C) 1998 Olivetti & Oracle Research Laboratory
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 */
13
14/* D3DES (V5.09) -
15 *
16 * A portable, public domain, version of the Data Encryption Standard.
17 *
18 * Written with Symantec's THINK (Lightspeed) C by Richard Outerbridge.
19 * Thanks to: Dan Hoey for his excellent Initial and Inverse permutation
20 * code; Jim Gillogly & Phil Karn for the DES key schedule code; Dennis
21 * Ferguson, Eric Young and Dana How for comparing notes; and Ray Lau,
22 * for humouring me on.
23 *
24 * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge.
25 * (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992.
26 */
27
28#include "d3des.h"
29
30static void scrunch(unsigned char *, unsigned long *);
31static void unscrun(unsigned long *, unsigned char *);
32static void desfunc(unsigned long *, unsigned long *);
33static void cookey(unsigned long *);
34
35static unsigned long KnL[32] = { 0L };
36static unsigned long KnR[32] = { 0L };
37static unsigned long Kn3[32] = { 0L };
38static unsigned char Df_Key[24] = {
39 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
40 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
41 0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
42
43 static unsigned short bytebit[8]= {
44 01, 02, 04, 010, 020, 040, 0100, 0200 };
45
46static unsigned long bigbyte[24] = {
47 0x800000L, 0x400000L, 0x200000L,0x100000L,
48 0x80000L, 0x40000L, 0x20000L,0x10000L,
49 0x8000L, 0x4000L, 0x2000L,0x1000L,
50 0x800L, 0x400L, 0x200L, 0x100L,
51 0x80L, 0x40L, 0x20L, 0x10L,
52 0x8L, 0x4L, 0x2L, 0x1L};
53
54/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
55
56static unsigned char pc1[56] = {
57 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17,
58 9, 1, 58, 50, 42, 34, 26,18, 10, 2, 59, 51, 43, 35,
59 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
60 13, 5, 60, 52, 44, 36, 28,20, 12, 4, 27, 19, 11, 3 };
61
62static unsigned char totrot[16] = {
63 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
64
65static unsigned char pc2[48] = {
66 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
67 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
68 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
69 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
70
71 void deskey(key, edf)/* Thanks to James Gillogly & Phil Karn! */
72unsigned char *key;
73short edf;
74{
75 register int i, j, l, m, n;
76 unsigned char pc1m[56], pcr[56];
77 unsigned long kn[32];
78
79 for ( j = 0; j < 56; j++ ) {
80 l = pc1[j];
81 m = l & 07;
82 pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
83 }
84 for( i = 0; i < 16; i++ ) {
85 if( edf == DE1 ) m = (15 - i) << 1;
86 else m = i << 1;
87 n = m + 1;
88 kn[m] = kn[n] = 0L;
89 for( j = 0; j < 28; j++ ) {
90 l = j + totrot[i];
91 if( l < 28 ) pcr[j] = pc1m[l];
92 else pcr[j] = pc1m[l - 28];
93 }
94 for( j = 28; j < 56; j++ ) {
95 l = j + totrot[i];
96 if( l < 56 ) pcr[j] = pc1m[l];
97 else pcr[j] = pc1m[l - 28];
98 }
99 for( j = 0; j < 24; j++ ) {
100 if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
101 if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
102 }
103 }
104 cookey(kn);
105 return;
106 }
107
108static void cookey(raw1)
109register unsigned long *raw1;
110{
111 register unsigned long *cook, *raw0;
112 unsigned long dough[32];
113 register int i;
114
115 cook = dough;
116 for( i = 0; i < 16; i++, raw1++ ) {
117 raw0 = raw1++;
118 *cook = (*raw0 & 0x00fc0000L) << 6;
119 *cook|= (*raw0 & 0x00000fc0L) << 10;
120 *cook|= (*raw1 & 0x00fc0000L) >> 10;
121 *cook++ |= (*raw1 & 0x00000fc0L) >> 6;
122 *cook = (*raw0 & 0x0003f000L) << 12;
123 *cook|= (*raw0 & 0x0000003fL) << 16;
124 *cook|= (*raw1 & 0x0003f000L) >> 4;
125 *cook++ |= (*raw1 & 0x0000003fL);
126 }
127 usekey(dough);
128 return;
129 }
130
131void cpkey(into)
132register unsigned long *into;
133{
134 register unsigned long *from, *endp;
135
136 from = KnL, endp = &KnL[32];
137 while( from < endp ) *into++ = *from++;
138 return;
139 }
140
141void usekey(from)
142register unsigned long *from;
143{
144 register unsigned long *to, *endp;
145
146 to = KnL, endp = &KnL[32];
147 while( to < endp ) *to++ = *from++;
148 return;
149 }
150
151void des(inblock, outblock)
152unsigned char *inblock, *outblock;
153{
154 unsigned long work[2];
155
156 scrunch(inblock, work);
157 desfunc(work, KnL);
158 unscrun(work, outblock);
159 return;
160 }
161
162static void scrunch(outof, into)
163register unsigned char *outof;
164register unsigned long *into;
165{
166 *into = (*outof++ & 0xffL) << 24;
167 *into|= (*outof++ & 0xffL) << 16;
168 *into|= (*outof++ & 0xffL) << 8;
169 *into++ |= (*outof++ & 0xffL);
170 *into = (*outof++ & 0xffL) << 24;
171 *into|= (*outof++ & 0xffL) << 16;
172 *into|= (*outof++ & 0xffL) << 8;
173 *into|= (*outof & 0xffL);
174 return;
175 }
176
177static void unscrun(outof, into)
178register unsigned long *outof;
179register unsigned char *into;
180{
181 *into++ = (*outof >> 24) & 0xffL;
182 *into++ = (*outof >> 16) & 0xffL;
183 *into++ = (*outof >> 8) & 0xffL;
184 *into++ = *outof++ & 0xffL;
185 *into++ = (*outof >> 24) & 0xffL;
186 *into++ = (*outof >> 16) & 0xffL;
187 *into++ = (*outof >> 8) & 0xffL;
188 *into = *outof & 0xffL;
189 return;
190 }
191
192static unsigned long SP1[64] = {
193 0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
194 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
195 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
196 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
197 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
198 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
199 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
200 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
201 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
202 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
203 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
204 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
205 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
206 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
207 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
208 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
209
210static unsigned long SP2[64] = {
211 0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
212 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
213 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
214 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
215 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
216 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
217 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
218 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
219 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
220 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
221 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
222 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
223 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
224 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
225 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
226 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
227
228static unsigned long SP3[64] = {
229 0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
230 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
231 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
232 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
233 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
234 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
235 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
236 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
237 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
238 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
239 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
240 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
241 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
242 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
243 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
244 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
245
246static unsigned long SP4[64] = {
247 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
248 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
249 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
250 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
251 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
252 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
253 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
254 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
255 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
256 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
257 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
258 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
259 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
260 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
261 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
262 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
263
264static unsigned long SP5[64] = {
265 0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
266 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
267 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
268 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
269 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
270 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
271 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
272 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
273 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
274 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
275 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
276 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
277 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
278 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
279 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
280 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
281
282static unsigned long SP6[64] = {
283 0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
284 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
285 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
286 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
287 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
288 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
289 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
290 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
291 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
292 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
293 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
294 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
295 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
296 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
297 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
298 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
299
300static unsigned long SP7[64] = {
301 0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
302 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
303 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
304 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
305 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
306 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
307 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
308 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
309 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
310 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
311 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
312 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
313 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
314 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
315 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
316 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
317
318static unsigned long SP8[64] = {
319 0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
320 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
321 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
322 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
323 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
324 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
325 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
326 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
327 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
328 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
329 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
330 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
331 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
332 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
333 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
334 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
335
336static void desfunc(block, keys)
337register unsigned long *block, *keys;
338{
339 register unsigned long fval, work, right, leftt;
340 register int round;
341
342 leftt = block[0];
343 right = block[1];
344 work = ((leftt >> 4) ^ right) & 0x0f0f0f0fL;
345 right ^= work;
346 leftt ^= (work << 4);
347 work = ((leftt >> 16) ^ right) & 0x0000ffffL;
348 right ^= work;
349 leftt ^= (work << 16);
350 work = ((right >> 2) ^ leftt) & 0x33333333L;
351 leftt ^= work;
352 right ^= (work << 2);
353 work = ((right >> 8) ^ leftt) & 0x00ff00ffL;
354 leftt ^= work;
355 right ^= (work << 8);
356 right = ((right << 1) | ((right >> 31) & 1L)) & 0xffffffffL;
357 work = (leftt ^ right) & 0xaaaaaaaaL;
358 leftt ^= work;
359 right ^= work;
360 leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
361
362 for( round = 0; round < 8; round++ ) {
363 work = (right << 28) | (right >> 4);
364 work ^= *keys++;
365 fval = SP7[ work & 0x3fL];
366 fval |= SP5[(work >> 8) & 0x3fL];
367 fval |= SP3[(work >> 16) & 0x3fL];
368 fval |= SP1[(work >> 24) & 0x3fL];
369 work = right ^ *keys++;
370 fval |= SP8[ work & 0x3fL];
371 fval |= SP6[(work >> 8) & 0x3fL];
372 fval |= SP4[(work >> 16) & 0x3fL];
373 fval |= SP2[(work >> 24) & 0x3fL];
374 leftt ^= fval;
375 work = (leftt << 28) | (leftt >> 4);
376 work ^= *keys++;
377 fval = SP7[ work & 0x3fL];
378 fval |= SP5[(work >> 8) & 0x3fL];
379 fval |= SP3[(work >> 16) & 0x3fL];
380 fval |= SP1[(work >> 24) & 0x3fL];
381 work = leftt ^ *keys++;
382 fval |= SP8[ work & 0x3fL];
383 fval |= SP6[(work >> 8) & 0x3fL];
384 fval |= SP4[(work >> 16) & 0x3fL];
385 fval |= SP2[(work >> 24) & 0x3fL];
386 right ^= fval;
387 }
388
389 right = (right << 31) | (right >> 1);
390 work = (leftt ^ right) & 0xaaaaaaaaL;
391 leftt ^= work;
392 right ^= work;
393 leftt = (leftt << 31) | (leftt >> 1);
394 work = ((leftt >> 8) ^ right) & 0x00ff00ffL;
395 right ^= work;
396 leftt ^= (work << 8);
397 work = ((leftt >> 2) ^ right) & 0x33333333L;
398 right ^= work;
399 leftt ^= (work << 2);
400 work = ((right >> 16) ^ leftt) & 0x0000ffffL;
401 leftt ^= work;
402 right ^= (work << 16);
403 work = ((right >> 4) ^ leftt) & 0x0f0f0f0fL;
404 leftt ^= work;
405 right ^= (work << 4);
406 *block++ = right;
407 *block = leftt;
408 return;
409 }
410
411/* Validation sets:
412 *
413 * Single-length key, single-length plaintext -
414 * Key : 0123 4567 89ab cdef
415 * Plain : 0123 4567 89ab cde7
416 * Cipher : c957 4425 6a5e d31d
417 *
418 * Double-length key, single-length plaintext -
419 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210
420 * Plain : 0123 4567 89ab cde7
421 * Cipher : 7f1d 0a77 826b 8aff
422 *
423 * Double-length key, double-length plaintext -
424 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210
425 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff
426 * Cipher : 27a0 8440 406a df60 278f 47cf 42d6 15d7
427 *
428 * Triple-length key, single-length plaintext -
429 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567
430 * Plain : 0123 4567 89ab cde7
431 * Cipher : de0b 7c06 ae5e 0ed5
432 *
433 * Triple-length key, double-length plaintext -
434 * Key : 0123 4567 89ab cdef fedc ba98 7654 3210 89ab cdef 0123 4567
435 * Plain : 0123 4567 89ab cdef 0123 4567 89ab cdff
436 * Cipher : ad0d 1b30 ac17 cf07 0ed1 1c63 81e4 4de5
437 *
438 * d3des V5.0a rwo 9208.07 18:44 Graven Imagery
439 **********************************************************************/
diff --git a/noncore/comm/keypebble/d3des.h b/noncore/comm/keypebble/d3des.h
new file mode 100644
index 0000000..5da6013
--- a/dev/null
+++ b/noncore/comm/keypebble/d3des.h
@@ -0,0 +1,50 @@
1/*
2 * This is D3DES (V5.09) by Richard Outerbridge with the double and
3 * triple-length support removed for use in VNC.
4 *
5 * These changes are Copyright (C) 1998 Olivetti & Oracle Research Laboratory
6 *
7 * This software is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11
12/* d3des.h -
13 *
14 *Headers and defines for d3des.c
15 *Graven Imagery, 1992.
16 *
17 * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
18 *(GEnie : OUTER; CIS : [71755,204])
19 */
20
21 #define EN0 0/* MODE == encrypt */
22 #define DE1 1/* MODE == decrypt */
23
24extern void deskey(unsigned char *, short);
25 /* hexkey[8] MODE
26 * Sets the internal key register according to the hexadecimal
27 * key contained in the 8 bytes of hexkey, according to the DES,
28 * for encryption or decryption according to MODE.
29 */
30
31extern void usekey(unsigned long *);
32 /* cookedkey[32]
33 * Loads the internal key register with the data in cookedkey.
34 */
35
36extern void cpkey(unsigned long *);
37 /* cookedkey[32]
38 * Copies the contents of the internal key register into the storage
39 * located at &cookedkey[0].
40 */
41
42extern void des(unsigned char *, unsigned char *);
43 /* from[8] to[8]
44 * Encrypts/Decrypts (according to the key currently loaded in the
45 * internal key register) one block of eight bytes at address 'from'
46 * into the block at address 'to'. They can be the same.
47 */
48
49/* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery
50 ********************************************************************/
diff --git a/noncore/comm/keypebble/keypebble.pro b/noncore/comm/keypebble/keypebble.pro
new file mode 100644
index 0000000..6b11801
--- a/dev/null
+++ b/noncore/comm/keypebble/keypebble.pro
@@ -0,0 +1,38 @@
1TEMPLATE = app
2
3CONFIG += qt warn_on release
4DESTDIR = ../bin
5
6 HEADERS = d3des.h \
7 krfbbuffer.h \
8 krfbcanvas.h \
9 krfbconnection.h \
10 krfbdecoder.h \
11 krfblogin.h \
12 krfboptions.h \
13 krfbserverinfo.h \
14 kvnc.h \
15 kvncconnectdlg.h \
16 kvncoptionsdlg.h \
17 version.h \
18 vncauth.h
19
20 SOURCES = d3des.c \
21 vncauth.c \
22 krfbbuffer.cpp \
23 krfbcanvas.cpp \
24 krfbconnection.cpp \
25 krfbdecoder.cpp \
26 krfblogin.cpp \
27 krfboptions.cpp \
28 kvnc.cpp \
29 kvncconnectdlg.cpp \
30 kvncoptionsdlg.cpp \
31 main.cpp
32 INTERFACES= vncoptionsbase.ui
33TARGET = keypebble
34
35INCLUDEPATH += $(QPEDIR)/include
36DEPENDPATH += $(QPEDIR)/include
37LIBS += -lqpe
38
diff --git a/noncore/comm/keypebble/krfbbuffer.cpp b/noncore/comm/keypebble/krfbbuffer.cpp
new file mode 100644
index 0000000..4885261
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbbuffer.cpp
@@ -0,0 +1,163 @@
1#include <assert.h>
2#include <qpixmap.h>
3#include <qbrush.h>
4#include <qimage.h>
5#include <qpainter.h>
6#include <qapplication.h>
7#include "krfbdecoder.h"
8#include "krfbbuffer.h"
9#include "krfbserverinfo.h"
10
11//
12// Endian stuff
13//
14#ifndef KDE_USE_FINAL
15const int endianTest = 1;
16#endif
17
18#define Swap16IfLE(s) \
19 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
20
21#define Swap32IfLE(l) \
22 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
23 (((l) & 0x00ff0000) >> 8) | \
24 (((l) & 0x0000ff00) << 8) | \
25 (((l) & 0x000000ff) << 24)) : (l))
26
27KRFBBuffer::KRFBBuffer( KRFBDecoder *decoder,
28 QObject *parent, const char *name )
29 : QObject( parent, name )
30{
31 assert( decoder );
32 this->decoder = decoder;
33 pix = new QPixmap();
34}
35
36KRFBBuffer::~KRFBBuffer()
37{
38 delete pix;
39}
40
41void KRFBBuffer::resize( int w, int h )
42{
43 qWarning( "Resizing buffer" );
44
45 pix->resize( w, h );
46
47 QPalette pal = qApp->palette();
48 pix->fill( pal.active().base() );
49
50 emit sizeChanged( w, h );
51}
52
53void KRFBBuffer::soundBell()
54{
55 emit bell();
56}
57
58void KRFBBuffer::mouseEvent( QMouseEvent *e )
59{
60 decoder->sendMouseEvent( e );
61}
62
63void KRFBBuffer::keyPressEvent( QKeyEvent *e )
64{
65 qWarning( "Buffer got a key" );
66
67 decoder->sendKeyPressEvent( e );
68}
69
70void KRFBBuffer::keyReleaseEvent( QKeyEvent *e )
71{
72 decoder->sendKeyReleaseEvent( e );
73}
74
75void KRFBBuffer::copyRect( int srcX, int srcY,
76 int destX, int destY, int w, int h )
77{
78// qWarning( "Got copy rect" );
79 bitBlt( pix, destX, destY, pix, srcX, srcY, w, h, CopyROP );
80
81 emit updated( destX, destY, w, h );
82}
83
84void KRFBBuffer::drawRawRectChunk( void *data,
85 int x, int y, int w, int h )
86{
87 QImage img( w, h, 32 );
88
89 int redMax = Swap16IfLE( decoder->format->redMax );
90 int greenMax = Swap16IfLE( decoder->format->greenMax );
91 int blueMax = Swap16IfLE( decoder->format->blueMax );
92
93 QPainter p( pix );
94
95 if ( decoder->format->bpp == 8 ) {
96 uchar *d = (unsigned char *) data;
97
98 uint r,g,b;
99
100 for ( int j = 0; j < h; j++ ) {
101 for ( int i = 0; i < w ; i++ ) {
102 r = d[ j * w + i ];
103 r = r >> decoder->format->redShift;
104 r = r & redMax;
105
106 g = d[ j * w + i ];
107 g = g >> decoder->format->greenShift;
108 g = g & greenMax;
109
110 b = d[ j * w + i ];
111 b = b >> decoder->format->blueShift;
112 b = b & blueMax;
113
114 r = ( r * 255 ) / redMax;
115 g = ( g * 255 ) / greenMax;
116 b = ( b * 255 ) / blueMax;
117
118 uint *p = ( uint * ) img.scanLine( j ) + i;
119 *p = qRgb( r,g,b );
120 }
121 }
122 }
123 else if ( decoder->format->bpp == 32 ) {
124 ulong *d = (ulong *) data;
125
126 ulong r,g,b;
127
128 for ( int j = 0; j < h; j++ ) {
129 for ( int i = 0; i < w ; i++ ) {
130 ulong pixel = d[ j * w + i ];
131 pixel = Swap32IfLE( pixel );
132
133 r = pixel;
134 r = r >> decoder->format->redShift;
135 r = r & redMax;
136
137 g = pixel;
138 g = g >> decoder->format->greenShift;
139 g = g & greenMax;
140
141 b = pixel;
142 b = b >> decoder->format->blueShift;
143 b = b & blueMax;
144
145 r = ( r * 255 ) / redMax;
146 g = ( g * 255 ) / greenMax;
147 b = ( b * 255 ) / blueMax;
148
149 uint *p = ( uint * ) img.scanLine( j ) + i;
150 *p = qRgb( r,g,b );
151 }
152 }
153 }
154 else {
155 p.setBrush( QBrush( Qt::black ) );
156 p.drawRect( x, y, w, h );
157 }
158
159 p.drawImage( x, y, img );
160
161 emit updated( x, y, w, h );
162}
163
diff --git a/noncore/comm/keypebble/krfbbuffer.h b/noncore/comm/keypebble/krfbbuffer.h
new file mode 100644
index 0000000..1116d00
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbbuffer.h
@@ -0,0 +1,62 @@
1// -*- c++ -*-
2
3#ifndef KRFBBUFFER_H
4#define KRFBBUFFER_H
5
6#include <qobject.h>
7
8class QPixmap;
9class KRFBDecoder;
10class QMouseEvent;
11class QKeyEvent;
12
13/**
14 * A wrapper around QPixmap that knows how to implement the RFB
15 * drawing primitives. If possible it makes use of the MIT XSHM
16 * extension to optimise the drawing operations.
17 */
18class KRFBBuffer : public QObject
19{
20 Q_OBJECT
21
22public:
23 KRFBBuffer( KRFBDecoder *decoder, QObject *parent, const char *name=0 );
24 ~KRFBBuffer();
25
26 QPixmap *pixmap() const { return pix; };
27
28 /**
29 * Draw a chunk of a raw encoded rectangle.
30 */
31 void drawRawRectChunk( void *data, int x, int y, int w, int h );
32
33 void copyRect( int srcX, int srcY,
34 int destX, int destY, int w, int h );
35
36 void fillRect( int ,int , int , int , unsigned long ) {};
37
38 void resize( int w, int h );
39
40 void mouseEvent( QMouseEvent *e );
41
42 void keyPressEvent( QKeyEvent *e );
43 void keyReleaseEvent( QKeyEvent *e );
44
45 void soundBell();
46
47signals:
48 /**
49 * Emitted when the size of the buffer changes.
50 */
51 void sizeChanged( int w, int h );
52
53 void updated( int x, int y, int w, int h );
54
55 void bell();
56
57private:
58 KRFBDecoder *decoder;
59 QPixmap *pix;
60};
61
62#endif // KRFBBUFFER_H
diff --git a/noncore/comm/keypebble/krfbcanvas.cpp b/noncore/comm/keypebble/krfbcanvas.cpp
new file mode 100644
index 0000000..f74ab7b
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbcanvas.cpp
@@ -0,0 +1,169 @@
1#include "kvncconnectdlg.h"
2#include "krfbconnection.h"
3#include "krfbcanvas.h"
4#include "krfboptions.h"
5#include "krfbbuffer.h"
6
7#include <qpe/config.h>
8
9#include <qapplication.h>
10#include <qclipboard.h>
11#include <qaction.h>
12#include <qpixmap.h>
13#include <qapplication.h>
14#include <qmainwindow.h>
15#include <qiconset.h>
16
17KRFBCanvas::KRFBCanvas( QWidget *parent, const char *name )
18 : QScrollView( parent, name )
19{
20 connection_ = new KRFBConnection();
21 connect( connection_, SIGNAL( passwordRequired( KRFBConnection * ) ),
22 this, SLOT( passwordRequired( KRFBConnection * ) ) );
23 connect( connection_, SIGNAL( loggedIn() ),
24 this, SLOT( loggedIn() ) );
25
26 loggedIn_ = false;
27
28 viewport()->setFocusPolicy( QWidget::StrongFocus );
29 viewport()->setFocus();
30}
31
32KRFBCanvas::~KRFBCanvas()
33{
34}
35
36void KRFBCanvas::openConnection()
37{
38 KVNCConnectDlg dlg( connection_, this, "connect dialog" );
39 if ( dlg.exec() ) {
40 QCString host = dlg.hostname().latin1();
41 password = dlg.password();
42 connection_->connectTo( host, dlg.display() );
43 }
44}
45
46void KRFBCanvas::openURL( const QUrl &url )
47{
48 if ( loggedIn_ ) {
49 qWarning( "openURL invoked when logged in\n" );
50 return;
51 }
52
53 QCString host = url.host().latin1();
54 int display = url.port();
55 if ( url.hasPassword() )
56 connection_->setPassword( url.password().latin1() );
57
58 connection_->connectTo( host, display );
59}
60
61void KRFBCanvas::closeConnection()
62{
63 loggedIn_ = false;
64 connection_->disconnect();
65
66 viewport()->setMouseTracking( false );
67 viewport()->setBackgroundMode( PaletteDark );
68 setBackgroundMode( PaletteDark );
69 update();
70}
71
72void KRFBCanvas::passwordRequired( KRFBConnection *con )
73{
74 con->setPassword( password.latin1() );
75}
76
77void KRFBCanvas::bell()
78{
79 if ( connection_->options()->deIconify ) {
80 topLevelWidget()->raise();
81 topLevelWidget()->show();
82 }
83}
84
85void KRFBCanvas::loggedIn()
86{
87 qWarning( "Ok, we're logged in" );
88
89 //
90 // Get ready for action
91 //
92 loggedIn_ = true;
93 viewport()->setMouseTracking( true );
94 viewport()->setBackgroundMode( NoBackground );
95 setBackgroundMode( NoBackground );
96
97 // Start using the buffer
98 connect( connection_->buffer(), SIGNAL( sizeChanged( int, int ) ),
99 this, SLOT( resizeContents(int,int) ) );
100 connect( connection_->buffer(), SIGNAL( updated( int, int, int, int ) ),
101 this, SLOT( viewportUpdate(int,int,int,int) ) );
102 connect( connection_->buffer(), SIGNAL( bell() ),
103 this, SLOT( bell() ) );
104 connect( qApp->clipboard(), SIGNAL( dataChanged() ),
105 this, SLOT( clipboardChanged() ) );
106}
107
108void KRFBCanvas::viewportPaintEvent( QPaintEvent *e )
109{
110 QRect r = e->rect();
111
112 if ( loggedIn_ ) {
113 bitBlt( viewport(), r.x(), r.y(),
114 connection_->buffer()->pixmap(),
115 r.x() + contentsX(), r.y() + contentsY(),
116 r.width(), r.height() );
117 }
118 else {
119 QScrollView::viewportPaintEvent( e );
120 }
121}
122
123void KRFBCanvas::viewportUpdate( int x, int y, int w, int h )
124{
125 updateContents( x, y, w, h );
126}
127
128void KRFBCanvas::contentsMousePressEvent( QMouseEvent *e )
129{
130 if ( loggedIn_ )
131 connection_->buffer()->mouseEvent( e );
132}
133
134void KRFBCanvas::contentsMouseReleaseEvent( QMouseEvent *e )
135{
136 if ( loggedIn_ )
137 connection_->buffer()->mouseEvent( e );
138}
139
140void KRFBCanvas::contentsMouseMoveEvent( QMouseEvent *e )
141{
142 if ( loggedIn_ )
143 connection_->buffer()->mouseEvent( e );
144}
145
146void KRFBCanvas::keyPressEvent( QKeyEvent *e )
147{
148 if ( loggedIn_ )
149 connection_->buffer()->keyPressEvent( e );
150}
151
152void KRFBCanvas::keyReleaseEvent( QKeyEvent *e )
153{
154 if ( loggedIn_ )
155 connection_->buffer()->keyReleaseEvent( e );
156}
157
158void KRFBCanvas::refresh()
159{
160 if ( loggedIn_ )
161 connection_->refresh();
162}
163
164void KRFBCanvas::clipboardChanged()
165{
166 if ( loggedIn_ ) {
167 connection_->sendCutText( qApp->clipboard()->text() );
168 }
169}
diff --git a/noncore/comm/keypebble/krfbcanvas.h b/noncore/comm/keypebble/krfbcanvas.h
new file mode 100644
index 0000000..7864f1c
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbcanvas.h
@@ -0,0 +1,54 @@
1// -*- c++ -*-
2
3#ifndef KRFBCANVAS_H
4#define KRFBCANVAS_H
5
6#include <qscrollview.h>
7#include <qurl.h>
8
9class KRFBConnection;
10
11/**
12 * Displays data from an KRFBDecoder, and sends events to the
13 * KRFBConnection.
14 */
15class KRFBCanvas : public QScrollView
16{
17 Q_OBJECT
18public:
19 KRFBCanvas( QWidget *parent, const char *name=0 );
20 ~KRFBCanvas();
21
22 void setConnection( KRFBConnection * );
23 KRFBConnection *connection() { return connection_; };
24
25public slots:
26 void openConnection();
27 void openURL( const QUrl & );
28 void closeConnection();
29 void passwordRequired( KRFBConnection * );
30
31 void refresh();
32 void bell();
33
34protected:
35 virtual void keyPressEvent( QKeyEvent * );
36 virtual void keyReleaseEvent( QKeyEvent * );
37 virtual void contentsMousePressEvent( QMouseEvent * );
38 virtual void contentsMouseReleaseEvent( QMouseEvent * );
39 virtual void contentsMouseMoveEvent( QMouseEvent * );
40
41 virtual void viewportPaintEvent( QPaintEvent *e );
42
43protected slots:
44 void loggedIn();
45 void viewportUpdate( int x, int y, int w, int h );
46 void clipboardChanged();
47
48private:
49 KRFBConnection *connection_;
50 QString password;
51 bool loggedIn_;
52};
53
54#endif // KRFBCANVAS_H
diff --git a/noncore/comm/keypebble/krfbconnection.cpp b/noncore/comm/keypebble/krfbconnection.cpp
new file mode 100644
index 0000000..c413186
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbconnection.cpp
@@ -0,0 +1,242 @@
1#include <assert.h>
2#include <qsocket.h>
3#include <qtimer.h>
4#include <string.h>
5
6#include "krfbconnection.h"
7#include "krfblogin.h"
8#include "krfboptions.h"
9#include "krfbdecoder.h"
10#include "krfbbuffer.h"
11
12KRFBConnection::KRFBConnection( QObject *parent )
13 : QObject( parent, "KRFBConnection" )
14{
15 portBase_ = 5900;
16 currentState_ = Disconnected;
17 sock = 0;
18 minData_ = 0;
19 options_ = new KRFBOptions();
20 updater = 0;
21 decoder_ = 0;
22 buffer_ = 0;
23}
24
25KRFBConnection::~KRFBConnection()
26{
27 if ( ( currentState_ != Disconnected ) && ( currentState_ != Disconnecting ) && sock ) {
28 disconnectDone();
29 }
30 delete options_;
31}
32
33void KRFBConnection::connectTo( const QCString &host, int display )
34{
35 if ( currentState_ != Disconnected );
36 disconnect();
37
38 this->host_= host;
39 this->display_ = display;
40
41 sock = new QSocket( this, "rfbSocket" );
42 CHECK_PTR( sock );
43
44 // Connect to something to notice connection or error
45 connect( sock, SIGNAL( error( int ) ), SLOT( gotSocketError( int ) ) );
46 connect( sock, SIGNAL( connected() ), SLOT( gotSocketConnection() ) );
47
48 qWarning( "Connecting..." );
49
50 currentState_ = Connecting;
51 sock->connectToHost( host_, portBase_ + display_ );
52}
53
54void KRFBConnection::disconnect()
55{
56 qWarning( "Disconnecting from server" );
57
58 if ( ( currentState_ != Disconnected )
59 && ( currentState_ != Disconnecting )
60 && sock ) {
61 currentState_ = Disconnecting;
62
63 connect( sock, SIGNAL( delayedCloseFinished() ), SLOT( disconnectDone() ) );
64 sock->close();
65
66 if ( sock->state() != QSocket::Closing )
67 disconnectDone();
68 }
69}
70
71void KRFBConnection::disconnectDone()
72{
73 qWarning( "KRFBConnection disconnected" );
74 currentState_ = Disconnected;
75 delete sock;
76 sock = 0;
77 minData_ = 0;
78 delete updater;
79 delete decoder_;
80 delete buffer_;
81 emit disconnected();
82}
83
84void KRFBConnection::gotSocketConnection()
85{
86 currentState_ = LoggingIn;
87
88 qWarning( "Connected, logging in..." );
89
90 static QString statusMsg = tr( "Connected" );
91 emit statusChanged( statusMsg );
92
93 // Do some login stuff
94 login = new KRFBLogin( this );
95}
96
97void KRFBConnection::gotRFBConnection()
98{
99 qWarning( "Logged into server" );
100
101 currentState_ = Connected;
102 emit connected();
103
104 // Create the decoder and start doing stuff
105 decoder_ = new KRFBDecoder( this );
106 CHECK_PTR( decoder_ );
107
108 buffer_ = new KRFBBuffer( decoder_, this, "RFB Buffer" );
109 CHECK_PTR( buffer_ );
110 decoder_->setBuffer( buffer_ );
111
112 connect( decoder_, SIGNAL( status( const QString & ) ),
113 this, SIGNAL( statusChanged( const QString & ) ) );
114 emit loggedIn();
115
116 decoder_->start();
117
118 updater = new QTimer;
119 connect( updater, SIGNAL( timeout() ), SLOT( updateTimer() ) );
120 updater->start( options_->updateRate );
121}
122
123void KRFBConnection::gotSocketError( int errno )
124{
125 currentState_ = Error;
126
127 // Do some error handling stuff
128 qWarning( "KRFBConnection: Socket error %d", errno );
129
130 static QString refused = tr( "Connection Refused" );
131 static QString host = tr( "Host not found" );
132 static QString read = tr( "Read Error: QSocket reported an error reading\n"
133 "data, the remote host has probably dropped the\n"
134 "connection." );
135 static QString confused = tr( "QSocket reported an invalid error code" );
136
137 QString msg;
138 switch ( errno ) {
139 case QSocket::ErrConnectionRefused:
140 msg = refused;
141 break;
142 case QSocket::ErrHostNotFound:
143 msg = host;
144 break;
145 case QSocket::ErrSocketRead:
146 msg = read;
147 break;
148 default:
149 msg = confused;
150 };
151
152 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) );
153 delete sock;
154 sock = 0;
155 currentState_ = Disconnected;
156
157 emit error( msg );
158}
159
160void KRFBConnection::gotMoreData()
161{
162 assert( minData_ > 0 );
163
164 if ( sock->size() >= minData_ ) {
165 minData_ = 0;
166 QObject::disconnect( sock, SIGNAL( readyRead() ), this, SLOT( gotMoreData() ) );
167 emit gotEnoughData();
168 }
169}
170
171void KRFBConnection::waitForData( unsigned int sz )
172{
173 assert( minData_ == 0 );
174 assert( sz > 0 );
175 assert( currentState_ != Error );
176
177 if ( sock->size() >= sz ) {
178 // qWarning( "No need to wait for data" );
179 emit gotEnoughData();
180 }
181 else {
182 // qWarning( "Waiting for %u bytes", sz );
183
184 minData_ = sz;
185 connect( sock, SIGNAL( readyRead() ), SLOT( gotMoreData() ) );
186 }
187}
188
189int KRFBConnection::read( void *buf, int sz )
190{
191 return sock->readBlock( (char *) buf, sz );
192}
193
194int KRFBConnection::write( void *buf, int sz )
195{
196 return sock->writeBlock( (const char *) buf, sz );
197}
198
199KRFBConnection::State KRFBConnection::state() const
200{
201 return currentState_;
202}
203
204void KRFBConnection::setPortBase( int base )
205{
206 portBase_ = base;
207}
208
209int KRFBConnection::portBase() const
210{
211 return portBase_;
212}
213
214void KRFBConnection::setPassword( const QCString &pass )
215{
216 this->pass_ = pass;
217}
218
219void KRFBConnection::updateTimer()
220{
221 decoder_->sendUpdateRequest( true );
222}
223
224void KRFBConnection::refresh()
225{
226 decoder_->sendUpdateRequest( false );
227}
228
229void KRFBConnection::sendCutText( const QString &text )
230{
231 decoder_->sendCutEvent( text );
232}
233
234const QUrl &KRFBConnection::url()
235{
236 url_.setProtocol( "vnc" );
237 url_.setPort( display() );
238 url_.setHost( host() );
239 url_.setPath( "/" );
240
241 return url_;
242}
diff --git a/noncore/comm/keypebble/krfbconnection.h b/noncore/comm/keypebble/krfbconnection.h
new file mode 100644
index 0000000..fe477c1
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbconnection.h
@@ -0,0 +1,152 @@
1// -*- c++ -*-
2
3#ifndef KRFBCONNECTION_H
4#define KRFBCONNECTION_H
5
6#include <qobject.h>
7#include <qstring.h>
8#include <qcstring.h>
9#include <qurl.h>
10
11class KRFBLogin;
12class KRBUpdateHandler;
13class KRFBOptions;
14class QSocket;
15class KRFBDecoder;
16class KRFBBuffer;
17class QTimer;
18
19/**
20 * Encapsulates the RFB socket.
21 *
22 */
23class KRFBConnection : public QObject
24{
25 Q_OBJECT
26
27public:
28 friend class KRFBLogin;
29 friend class KRFBDecoder;
30
31 //* The state of the connection.
32 enum State {
33 Connecting,
34 LoggingIn,
35 Connected,
36 Disconnecting,
37 Disconnected,
38 Error
39 };
40
41 KRFBConnection( QObject *parent = 0 );
42 ~KRFBConnection();
43
44 //* Get the state of a connection.
45 State state() const;
46
47 //* Get the options for this connection
48 KRFBOptions *options() const { return options_; };
49
50 KRFBBuffer *buffer() const { return buffer_; };
51
52 KRFBDecoder *decoder() const { return decoder_; };
53
54 //* Set the base from which the port for a given display will be calculated.
55 void setPortBase( int base );
56
57 //* Get the base from which the port for a given display is calculated.
58 int portBase() const;
59
60 //* Set the password which will be used to login
61 void setPassword( const QCString &pass );
62
63 //* Open a connection
64 void connectTo( const QCString &host, int display );
65
66 //* Close the connection
67 void disconnect();
68
69 //* Get the host
70 const QCString host() const { return host_; };
71
72 //* Get the display
73 int display() const { return display_; };
74
75 //* Get the current host/display as a URL
76 const QUrl &url();
77
78 //* Reload the display
79 void refresh();
80
81 //* Send text to the remote clipboard
82 void sendCutText( const QString & );
83
84protected slots:
85 //* When the shit hits the fan
86 void gotSocketError( int );
87
88 //* When we have an open socket
89 void gotSocketConnection();
90
91 //* When we have logged in
92 void gotRFBConnection();
93
94 //* When some more data arrived
95 void gotMoreData();
96
97 void updateTimer();
98
99 void disconnectDone();
100
101signals:
102 //* Emitted when the status of the connection changes.
103 void statusChanged( const QString & );
104
105 /**
106 * Emitted when we *really* need a password. If the password
107 * was specified before you tried to connect then you won't
108 * see this.
109 */
110 void passwordRequired( KRFBConnection * );
111
112 //* When we have a working RFB connection
113 void connected();
114
115 void loggedIn();
116
117 void disconnected();
118
119 //* What happened?
120 void error( const QString &msg );
121
122 //* Emitted in response to a waitForData() call.
123 void gotEnoughData();
124
125private:
126 //
127 // The following are called by our friends.
128 //
129
130 void waitForData( unsigned int );
131
132 int read( void *buf, int sz );
133 int write( void *buf, int sz );
134
135private:
136 QCString host_;
137 int portBase_;
138 int display_;
139 QCString pass_;
140 QSocket *sock;
141 State currentState_;
142 unsigned int minData_;
143 QTimer *updater;
144 KRFBLogin *login;
145 KRFBDecoder *decoder_;
146 KRFBOptions *options_;
147 KRFBBuffer *buffer_;
148 QUrl url_;
149};
150
151#endif // KRFBCONNECTION_H
152
diff --git a/noncore/comm/keypebble/krfbdecoder.cpp b/noncore/comm/keypebble/krfbdecoder.cpp
new file mode 100644
index 0000000..174dd7b
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbdecoder.cpp
@@ -0,0 +1,839 @@
1#include "krfbconnection.h"
2#include "krfboptions.h"
3#include "krfbserverinfo.h"
4#include "krfbdecoder.h"
5#include "krfbbuffer.h"
6
7#include <qpe/qpeapplication.h>
8
9#include <qpixmap.h>
10#include <qsocket.h>
11#include <qevent.h>
12#include <qstring.h>
13#include <qclipboard.h>
14
15#include <assert.h>
16
17//
18// Endian stuff
19//
20#ifndef KDE_USE_FINAL
21const int endianTest = 1;
22#endif
23
24#define Swap16IfLE(s) \
25 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
26
27#define Swap32IfLE(l) \
28 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
29 (((l) & 0x00ff0000) >> 8) | \
30 (((l) & 0x0000ff00) << 8) | \
31 (((l) & 0x000000ff) << 24)) : (l))
32
33//
34// The lengths of the messages we need to wait for
35//
36const int ServerInitLength = 24;
37const int UpdateHeaderLength = 4;
38const int RectHeaderLength = 12;
39const int RectChunkSize = 4;
40const int CopyRectPosLength = 4;
41const int ServerCutLenLength = 7;
42
43//
44// Client -> Server Message Identifiers
45//
46static CARD8 SetPixelFormatId = 0;
47//static CARD8 FixColourMapEntriesId = 1; // Not used
48static CARD8 SetEncodingsId = 2;
49static CARD8 UpdateRequestId = 3;
50static CARD8 KeyEventId = 4;
51static CARD8 PointerEventId = 5;
52static CARD8 ClientCutTextId = 6;
53
54//
55// Server -> Client Message Identifiers
56//
57static CARD8 UpdateId = 0;
58static CARD8 BellId = 2;
59static CARD8 ServerCutId = 3;
60
61//
62// Encoding identifiers
63//
64static CARD32 RawEncoding = Swap32IfLE( 0 );
65static CARD32 CopyRectEncoding = Swap32IfLE(1 );
66static CARD32 RreEncoding = Swap32IfLE( 2 );
67static CARD32 CorreEncoding = Swap32IfLE( 4 );
68static CARD32 HexTileEncoding = Swap32IfLE( 5 );
69
70static struct {
71 int keysym;
72 int keycode;
73} keyMap[] = {
74 { 0xff08, Qt::Key_Backspace },
75 { 0xff09, Qt::Key_Tab },
76 { 0xff0d, Qt::Key_Return },
77 { 0xff1b, Qt::Key_Escape },
78 { 0xff63, Qt::Key_Insert },
79 { 0xffff, Qt::Key_Delete },
80 { 0xff50, Qt::Key_Home },
81 { 0xff57, Qt::Key_End },
82 { 0xff55, Qt::Key_Prior },
83 { 0xff56, Qt::Key_Next },
84 { 0xff51, Qt::Key_Left },
85 { 0xff52, Qt::Key_Up },
86 { 0xff53, Qt::Key_Right },
87 { 0xff54, Qt::Key_Down },
88 { 0xffbe, Qt::Key_F1 },
89 { 0xffbf, Qt::Key_F2 },
90 { 0xffc0, Qt::Key_F3 },
91 { 0xffc1, Qt::Key_F4 },
92 { 0xffc2, Qt::Key_F5 },
93 { 0xffc3, Qt::Key_F6 },
94 { 0xffc4, Qt::Key_F7 },
95 { 0xffc5, Qt::Key_F8 },
96 { 0xffc6, Qt::Key_F9 },
97 { 0xffc7, Qt::Key_F10 },
98 { 0xffc8, Qt::Key_F11 },
99 { 0xffc9, Qt::Key_F12 },
100 { 0xffe1, Qt::Key_Shift },
101 { 0xffe2, Qt::Key_Shift },
102 { 0xffe3, Qt::Key_Control },
103 { 0xffe4, Qt::Key_Control },
104 { 0xffe7, Qt::Key_Meta },
105 { 0xffe8, Qt::Key_Meta },
106 { 0xffe9, Qt::Key_Alt },
107 { 0xffea, Qt::Key_Alt },
108 { 0, 0 }
109};
110
111
112KRFBDecoder::KRFBDecoder( KRFBConnection *con )
113 : QObject( con, "RFB Decoder" )
114{
115 assert( con );
116 assert( con->state() == KRFBConnection::Connected );
117
118 this->con = con;
119 this->buf = 0;
120 this->info = 0;
121 this->format = 0;
122 this->buttonMask = 0;
123 currentState = Idle;
124}
125
126KRFBDecoder::~KRFBDecoder()
127{
128 if ( info )
129 delete info;
130 if ( format )
131 delete format;
132}
133
134void KRFBDecoder::start()
135{
136 sendClientInit();
137}
138
139void KRFBDecoder::sendClientInit()
140{
141 con->write( &( con->options()->shared ), 1 );
142
143 // Wait for server init
144 qWarning( "Waiting for server init" );
145
146 static QString statusMsg = tr( "Waiting for server initialisation..." );
147 emit status( statusMsg );
148
149 currentState = AwaitingServerInit;
150 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerInit() ) );
151 con->waitForData( ServerInitLength );
152}
153
154void KRFBDecoder::gotServerInit()
155{
156 qWarning( "Got server init" );
157 disconnect( con, SIGNAL( gotEnoughData() ), this, SLOT( gotServerInit() ) );
158
159 if ( info )
160 delete info;
161 info = new KRFBServerInfo;
162 CHECK_PTR( info );
163
164 con->read( &(info->width), 2 );
165 info->width = Swap16IfLE( info->width );
166 con->read( &info->height, 2 );
167 info->height = Swap16IfLE( info->height );
168
169 con->read( &(info->bpp), 1 );
170 con->read( &(info->depth), 1 );
171 con->read( &(info->bigEndian), 1 );
172 con->read( &(info->trueColor), 1 );
173
174 con->read( &(info->redMax), 2 );
175 info->redMax = Swap16IfLE( info->redMax );
176 con->read( &(info->greenMax), 2 );
177 info->greenMax = Swap16IfLE( info->greenMax );
178 con->read( &(info->blueMax), 2 );
179 info->blueMax = Swap16IfLE( info->blueMax );
180
181 con->read( &(info->redShift), 1 );
182 con->read( &(info->greenShift), 1 );
183 con->read( &(info->blueShift), 1 );
184
185 con->read( info->padding, 3 );
186
187 con->read( &(info->nameLength), 4 );
188 info->nameLength = Swap32IfLE( info->nameLength );
189
190 qWarning( "Width = %d, Height = %d", info->width, info->height );
191 qWarning( "Bpp = %d, Depth = %d, Big = %d, True = %d",
192 info->bpp, info->depth, info->bigEndian, info->trueColor );
193 qWarning( "RedMax = %d, GreenMax = %d, BlueMax = %d",
194 info->redMax, info->greenMax, info->blueMax );
195 qWarning( "RedShift = %d, GreenShift = %d, BlueShift = %d",
196 info->redShift, info->greenShift,info-> blueShift );
197
198 buf->resize( info->width, info->height );
199
200 // Wait for desktop name
201 qWarning( "Waiting for desktop name" );
202
203 static QString statusMsg = tr( "Waiting for desktop name..." );
204 emit status( statusMsg );
205
206 currentState = AwaitingDesktopName;
207 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotDesktopName() ) );
208 con->waitForData( info->nameLength );
209}
210
211void KRFBDecoder::gotDesktopName()
212{
213 assert( info );
214 assert( currentState == AwaitingDesktopName );
215
216 qWarning( "Got desktop name" );
217
218 disconnect( con, SIGNAL( gotEnoughData() ),
219 this, SLOT( gotDesktopName() ) );
220
221 char *buf = new char[ info->nameLength + 1 ];
222 CHECK_PTR( buf );
223
224 con->read( buf, info->nameLength );
225 buf[ info->nameLength ] = '\0';
226 info->name = buf;
227
228 qWarning( "Desktop: %s", info->name.latin1() );
229
230 delete buf;
231
232 // Get the format we'll really use and tell the server
233 decidePixelFormat();
234 sendPixelFormat();
235 sendAllowedEncodings();
236 currentState = Idle;
237
238 QString msg;
239 msg = tr( "Connected to %1" );
240 msg = msg.arg( info->name );
241 emit status( msg );
242
243 sendUpdateRequest( false );
244}
245
246void KRFBDecoder::decidePixelFormat()
247{
248 assert( info );
249
250 if ( format )
251 delete format;
252 format = new KRFBPixelFormat;
253 CHECK_PTR( format );
254
255 // What depth do we want?
256 //
257 // We'll use the minimum of the remote and local depths, UNLESS an
258 // eight bit session has been specifically requested by the user.
259 int screenDepth = QPixmap::defaultDepth();
260 int bestDepth = ( screenDepth > info->depth ) ? info->depth : screenDepth;
261 int chosenDepth;
262
263 if ( con->options()->colors256 )
264 chosenDepth = 8;
265 else
266 chosenDepth = bestDepth;
267
268 qWarning( "Screen depth=%d, server depth=%d, best depth=%d, " \
269 "eight bit %d, chosenDepth=%d",
270 screenDepth,
271 info->depth,
272 bestDepth,
273 con->options()->colors256, chosenDepth );
274
275 format->depth = chosenDepth;
276
277 // If we're using the servers native depth
278 if ( chosenDepth == info->depth ) {
279 // Use the servers native format
280 format->bpp = info->bpp;
281 // format->bigEndian = info->bigEndian;
282 format->bigEndian = true;
283 format->trueColor = info->trueColor;
284 format->redMax = info->redMax;
285 format->greenMax = info->greenMax;
286 format->blueMax = info->blueMax;
287 format->redShift = info->redShift;
288 format->greenShift = info->greenShift;
289 format->blueShift = info->blueShift;
290 }
291 else {
292 if ( chosenDepth == 8 ) {
293 format->bpp = 8;
294 format->bigEndian = true;
295 format->trueColor = true;
296 format->redMax = 7;
297 format->greenMax = 7;
298 format->blueMax = 3;
299 format->redShift = 0;
300 format->greenShift = 3;
301 format->blueShift = 6;
302 }
303 }
304
305 format->redMax = Swap16IfLE( format->redMax );
306 format->greenMax = Swap16IfLE( format->greenMax );
307 format->blueMax = Swap16IfLE( format->blueMax );
308}
309
310void KRFBDecoder::sendPixelFormat()
311{
312 static char padding[3];
313 con->write( &SetPixelFormatId, 1 );
314 con->write( padding, 3 );
315
316 con->write( &(format->bpp), 1 );
317 con->write( &(format->depth), 1 );
318 con->write( &(format->bigEndian), 1 );
319 con->write( &(format->trueColor), 1 );
320
321 con->write( &(format->redMax), 2 );
322 con->write( &(format->greenMax), 2 );
323 con->write( &(format->blueMax), 2 );
324
325 con->write( &(format->redShift), 1 );
326 con->write( &(format->greenShift), 1 );
327 con->write( &(format->blueShift), 1 );
328 con->write( format->padding, 3 ); // Padding
329}
330
331void KRFBDecoder::sendAllowedEncodings()
332{
333 static CARD8 padding[1];
334 con->write( &SetEncodingsId, 1 );
335 con->write( padding, 1 );
336
337 static CARD16 noEncodings = con->options()->encodings();
338 noEncodings = Swap16IfLE( noEncodings );
339 con->write( &noEncodings, 2 );
340
341 if ( con->options()->corre )
342 con->write( &CorreEncoding, 4 );
343 if ( con->options()->hexTile )
344 con->write( &HexTileEncoding, 4 );
345 if ( con->options()->rre )
346 con->write( &RreEncoding, 4 );
347 if ( con->options()->copyrect )
348 con->write( &CopyRectEncoding, 4 );
349 // We always support this
350 con->write( &RawEncoding, 4 );
351}
352
353void KRFBDecoder::sendUpdateRequest( bool incremental )
354{
355 if ( currentState != Idle )
356 return;
357
358 con->write( &UpdateRequestId, 1 );
359 con->write( &incremental, 1 );
360
361 static CARD16 x = 0, y = 0;
362 static CARD16 w = Swap16IfLE( info->width );
363 static CARD16 h = Swap16IfLE( info->height );
364
365 con->write( &x, 2 );
366 con->write( &y, 2 );
367 con->write( &w, 2 );
368 con->write( &h, 2 );
369
370 // Now wait for the update
371 currentState = AwaitingUpdate;
372 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
373 con->waitForData( UpdateHeaderLength );
374}
375
376void KRFBDecoder::gotUpdateHeader()
377{
378 assert( currentState == AwaitingUpdate );
379
380 // qWarning( "Got update header" );
381
382 disconnect( con, SIGNAL( gotEnoughData() ),
383 this, SLOT( gotUpdateHeader() ) );
384
385 CARD8 msgType;
386 con->read( &msgType, 1 );
387
388 if ( msgType != UpdateId ) {
389 // We might have a bell or server cut
390 if ( msgType == ServerCutId ) {
391 oldState = currentState;
392 gotServerCut();
393 }
394 else if ( msgType == BellId ) {
395 oldState = currentState;
396 gotBell();
397 }
398 else {
399 int msg = msgType;
400 QString protocolError = tr( "Protocol Error: Message Id %1 was "
401 "found when expecting an update "
402 "message." ).arg( msg );
403 currentState = Error;
404 emit error( protocolError );
405 }
406 return;
407 }
408
409 CARD8 padding;
410 con->read( &padding, 1 );
411
412 con->read( &noRects, 2 );
413 noRects = Swap16IfLE( noRects );
414
415 // qWarning( "Expecting %d rects", noRects );
416
417 // Now wait for the data
418 currentState = AwaitingRectHeader;
419 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
420 con->waitForData( RectHeaderLength );
421}
422
423void KRFBDecoder::gotRectHeader()
424{
425 assert( currentState == AwaitingRectHeader );
426
427 // qWarning( "Got rect header" );
428
429 disconnect( con, SIGNAL( gotEnoughData() ),
430 this, SLOT( gotRectHeader() ) );
431
432 con->read( &x, 2 );
433 x = Swap16IfLE( x );
434 con->read( &y, 2 );
435 y = Swap16IfLE( y );
436
437 con->read( &w, 2 );
438 w = Swap16IfLE( w );
439 con->read( &h, 2 );
440 h = Swap16IfLE( h );
441
442 con->read( &encoding, 4 );
443
444 // CARD32 encodingLocal = Swap32IfLE( encoding );
445 // qWarning( "Rect: x=%d, y= %d, w=%d, h=%d, encoding=%ld",
446 // x, y, w, h, encodingLocal );
447
448 //
449 // Each encoding needs to be handled differently. Some require
450 // waiting for more data, but others like a copyrect do not.
451 // Our constants have already been byte swapped, so we use
452 // the remote value as is.
453 //
454 if ( encoding == RawEncoding ) {
455 // qWarning( "Raw encoding" );
456 handleRawRect();
457 }
458 else if ( encoding == CopyRectEncoding ) {
459// qWarning( "CopyRect encoding" );
460 handleCopyRect();
461 }
462 else if ( encoding == RreEncoding ) {
463 qWarning( "RRE encoding" );
464 handleRRERect();
465 }
466 else if ( encoding == CorreEncoding ) {
467 qWarning( "CoRRE encoding" );
468 handleCoRRERect();
469 }
470 else if ( encoding == HexTileEncoding ) {
471 qWarning( "HexTile encoding" );
472 handleHexTileRect();
473 }
474 else {
475 int msg = Swap32IfLE( encoding );
476 QString protocolError = tr( "Protocol Error: An unknown encoding was "
477 "used by the server %1" ).arg( msg );
478 currentState = Error;
479 qWarning( "Unknown encoding, %d", msg );
480 emit error( protocolError );
481 return;
482 }
483}
484
485//
486// Raw Encoding
487//
488
489void KRFBDecoder::handleRawRect()
490{
491 // We need something a bit cleverer here to handle large
492 // rectanges nicely. The chunking should be based on the
493 // overall size (but has to be in complete lines).
494
495 // qWarning( "Handling a raw rect chunk" );
496
497 // CARD32 lineCount = w * format->bpp / 8;
498
499 if ( h > RectChunkSize ) {
500 // if ( con->sock->size() / lineCount ) {
501 // getRawRectChunk( con->sock->size() / lineCount );
502 // }
503 // else {
504 getRawRectChunk( RectChunkSize );
505 // }
506 }
507 else {
508 getRawRectChunk( h );
509 }
510}
511
512void KRFBDecoder::getRawRectChunk( int lines )
513{
514 this->lines = lines;
515 CARD32 count = lines * w * format->bpp / 8;
516
517 // Wait for server init
518 // qWarning( "Waiting for raw rect chunk, %ld", count );
519
520 currentState = AwaitingRawRectChunk;
521 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRawRectChunk() ) );
522 con->waitForData( count );
523}
524
525void KRFBDecoder::gotRawRectChunk()
526{
527 assert( currentState == AwaitingRawRectChunk );
528
529 disconnect( con, SIGNAL( gotEnoughData() ),
530 this, SLOT( gotRawRectChunk() ) );
531
532 // qWarning( "Got raw rect chunk" );
533
534 //
535 // Read the rect data and copy it to the buffer.
536 //
537
538 // TODO: Replace this!
539 int count = lines * w * format->bpp / 8;
540 char *hack = new char[ count ];
541 con->read( hack, count );
542 buf->drawRawRectChunk( hack, x, y, w, lines );
543 delete hack;
544 // /TODO:
545
546 h = h - lines;
547 y = y + lines;
548
549 if ( h > 0 ) {
550 handleRawRect();
551 }
552 else {
553 noRects--;
554
555 // qWarning( "There are %d rects left", noRects );
556
557 if ( noRects ) {
558 currentState = AwaitingRectHeader;
559 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
560 con->waitForData( RectHeaderLength );
561 }
562 else
563 currentState = Idle;
564 }
565}
566
567//
568// Copy Rectangle Encoding
569//
570
571void KRFBDecoder::handleCopyRect()
572{
573 currentState = AwaitingCopyRectPos;
574 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotCopyRectPos() ) );
575 con->waitForData( CopyRectPosLength );
576}
577
578void KRFBDecoder::gotCopyRectPos()
579{
580 disconnect( con, SIGNAL( gotEnoughData() ),
581 this, SLOT( gotCopyRectPos() ) );
582
583 CARD16 srcX;
584 CARD16 srcY;
585
586 con->read( &srcX, 2 );
587 con->read( &srcY, 2 );
588
589 srcX = Swap16IfLE( srcX );
590 srcY = Swap16IfLE( srcY );
591
592 buf->copyRect( srcX, srcY, x, y, w, h );
593
594 noRects--;
595
596 // qWarning( "There are %d rects left", noRects );
597
598 if ( noRects ) {
599 currentState = AwaitingRectHeader;
600 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotRectHeader() ) );
601 con->waitForData( RectHeaderLength );
602 }
603 else
604 currentState = Idle;
605}
606
607void KRFBDecoder::handleRRERect()
608{
609 qWarning( "RRE not implemented" );
610}
611
612void KRFBDecoder::handleCoRRERect()
613{
614 qWarning( "CoRRE not implemented" );
615}
616
617void KRFBDecoder::handleHexTileRect()
618{
619 qWarning( "HexTile not implemented" );
620}
621
622void KRFBDecoder::sendMouseEvent( QMouseEvent *e )
623{
624 // Deal with the buttons
625 if ( e->type() != QEvent::MouseMove ) {
626 buttonMask = 0;
627 if ( e->type() == QEvent::MouseButtonPress ) {
628 if ( e->button() & LeftButton )
629 buttonMask |= 0x01;
630 if ( e->button() & MidButton )
631 buttonMask |= 0x04;
632 if ( e->button() & RightButton )
633 buttonMask |= 0x02;
634 }
635 else if ( e->type() == QEvent::MouseButtonRelease ) {
636 if ( e->button() & LeftButton )
637 buttonMask &= 0x06;
638 if ( e->button() & MidButton )
639 buttonMask |= 0x03;
640 if ( e->button() & RightButton )
641 buttonMask |= 0x05;
642 }
643 }
644
645 CARD16 x = Swap16IfLE( e->x() );
646 CARD16 y = Swap16IfLE( e->y() );
647
648 con->write( &PointerEventId, 1 );
649 con->write( &buttonMask, 1 );
650 con->write( &x, 2 );
651 con->write( &y, 2 );
652}
653
654
655void KRFBDecoder::sendCutEvent( const QString &unicode )
656{
657 //
658 // Warning: There is a bug in the RFB protocol because there is no way to find
659 // out the codepage in use on the remote machine. This could be fixed by requiring
660 // the remote server to use utf8 etc. but for now we have to assume they're the
661 // same. I've reported this problem to the ORL guys, but they apparantly have no
662 // immediate plans to fix the issue. :-( (rich)
663 //
664
665 CARD8 padding[3];
666 QCString text = unicode.local8Bit();
667 CARD32 length = text.length();
668 length = Swap32IfLE( length );
669
670 con->write( &ClientCutTextId, 1 );
671 con->write( &padding, 3 );
672 con->write( &length, 4 );
673 con->write( text.data(), length );
674}
675
676void KRFBDecoder::gotServerCut()
677{
678 qWarning( "Got server cut" );
679
680 currentState = AwaitingServerCutLength;
681 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutLength() ) );
682 con->waitForData( ServerCutLenLength );
683}
684
685void KRFBDecoder::gotServerCutLength()
686{
687 assert( currentState = AwaitingServerCutLength );
688 disconnect( con, SIGNAL( gotEnoughData() ),
689 this, SLOT( gotServerCutLength() ) );
690
691 CARD8 padding[3];
692 con->read( padding, 3 );
693
694 con->read( &serverCutTextLen, 4 );
695 serverCutTextLen = Swap32IfLE( serverCutTextLen );
696
697 currentState = AwaitingServerCutText;
698 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerCutText() ) );
699 con->waitForData( serverCutTextLen );
700}
701
702void KRFBDecoder::gotServerCutText()
703{
704 assert( currentState = AwaitingServerCutText );
705
706 disconnect( con, SIGNAL( gotEnoughData() ),
707 this, SLOT( gotServerCutText() ) );
708
709 //
710 // Warning: There is a bug in the RFB protocol because there is no way to find
711 // out the codepage in use on the remote machine. This could be fixed by requiring
712 // the remote server to use utf8 etc. but for now we have to assume they're the
713 // same. I've reported this problem to the ORL guys, but they apparantly have no
714 // immediate plans to fix the issue. :-( (rich)
715 //
716
717 char *cutbuf = new char[ serverCutTextLen + 1 ];
718 CHECK_PTR( cutbuf );
719
720 con->read( cutbuf, serverCutTextLen );
721 cutbuf[ serverCutTextLen ] = '\0';
722
723 qWarning( "Server cut: %s", cutbuf );
724
725 QString cutText( cutbuf ); // DANGER!!
726 qApp->clipboard()->setText( cutText );
727
728 delete cutbuf;
729
730 // Now wait for the update (again)
731 if ( oldState == AwaitingUpdate ) {
732 currentState = AwaitingUpdate;
733 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
734 con->waitForData( UpdateHeaderLength );
735 }
736 else if ( oldState == Idle ) {
737 currentState = Idle;
738 }
739 else {
740 qWarning( "Async handled in weird state" );
741 currentState = oldState;
742 };
743}
744
745void KRFBDecoder::gotBell()
746{
747 qWarning( "Got server bell" );
748 buf->soundBell();
749
750 // Now wait for the update (again)
751 if ( oldState == AwaitingUpdate ) {
752 currentState = AwaitingUpdate;
753 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotUpdateHeader() ) );
754 con->waitForData( UpdateHeaderLength );
755 }
756 else if ( oldState == Idle ) {
757 currentState = Idle;
758 }
759 else {
760 qWarning( "Async handled in weird state" );
761 currentState = oldState;
762 };
763}
764
765void KRFBDecoder::sendKeyPressEvent( QKeyEvent *event )
766{
767 int key;
768 key = toKeySym( event );
769 if ( key ) {
770 key = Swap32IfLE( key );
771
772 CARD8 mask = true;
773
774 CARD16 padding = 0;
775 con->write( &KeyEventId, 1 );
776 con->write( &mask, 1 );
777 con->write( &padding, 2 );
778 con->write( &key, 4 );
779 }
780}
781
782void KRFBDecoder::sendKeyReleaseEvent( QKeyEvent *event )
783{
784 int key;
785 key = toKeySym( event );
786 if ( key ) {
787 key = Swap32IfLE( key );
788
789 CARD8 mask = false;
790
791 CARD16 padding = 0;
792 con->write( &KeyEventId, 1 );
793 con->write( &mask, 1 );
794 con->write( &padding, 2 );
795 con->write( &key, 4 );
796 }
797}
798
799int KRFBDecoder::toKeySym( QKeyEvent *k )
800{
801 int ke = 0;
802
803 ke = k->ascii();
804 // Markus: Crappy hack. I dont know why lower case letters are
805 // not defined in qkeydefs.h. The key() for e.g. 'l' == 'L'.
806 // This sucks. :-(
807
808 if ( (ke == 'a') || (ke == 'b') || (ke == 'c') || (ke == 'd')
809 || (ke == 'e') || (ke == 'f') || (ke == 'g') || (ke == 'h')
810 || (ke == 'i') || (ke == 'j') || (ke == 'k') || (ke == 'l')
811 || (ke == 'm') || (ke == 'n') || (ke == 'o') || (ke == 'p')
812 || (ke == 'q') || (ke == 'r') || (ke == 's') || (ke == 't')
813 || (ke == 'u') || (ke == 'v') ||( ke == 'w') || (ke == 'x')
814 || (ke == 'y') || (ke == 'z') ) {
815 ke = k->key();
816 ke = ke + 0x20;
817 return ke;
818 }
819
820 // qkeydefs = xkeydefs! :-)
821 if ( ( k->key() >= 0x0a0 ) && k->key() <= 0x0ff )
822 return k->key();
823
824 if ( ( k->key() >= 0x20 ) && ( k->key() <= 0x7e ) )
825 return k->key();
826
827 // qkeydefs != xkeydefs! :-(
828 // This is gonna suck :-(
829
830 int i = 0;
831 while ( keyMap[i].keycode ) {
832 if ( k->key() == keyMap[i].keycode )
833 return keyMap[i].keysym;
834 i++;
835 }
836
837 return 0;
838}
839
diff --git a/noncore/comm/keypebble/krfbdecoder.h b/noncore/comm/keypebble/krfbdecoder.h
new file mode 100644
index 0000000..4ba0185
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbdecoder.h
@@ -0,0 +1,134 @@
1// -*- c++ -*-
2
3#ifndef KRFBDECODER_H
4#define KRFBDECODER_H
5
6#include <qobject.h>
7
8class KRFBConnection;
9class KRFBServerInfo;
10class KRFBPixelFormat;
11class KRFBBuffer;
12
13
14typedef unsigned char CARD8;
15typedef unsigned short CARD16;
16typedef unsigned long CARD32;
17
18/**
19 * Negotiates the pixel format to be used then decodes the resulting
20 * data stream.
21 *
22 * @author Richard Moore, rich@kde.org
23 */
24class KRFBDecoder : public QObject
25{
26 Q_OBJECT
27
28public:
29 friend class KRFBBuffer;
30
31 enum State {
32 AwaitingServerInit,
33 AwaitingDesktopName,
34 AwaitingUpdate,
35 AwaitingRectHeader,
36 AwaitingRawRectChunk,
37 AwaitingCopyRectPos,
38 AwaitingServerCutLength,
39 AwaitingServerCutText,
40 Idle,
41 Error
42 };
43
44 /**
45 * Create a KRFBDecoder that reads data from a logged in KRFBConnection
46 * and sends its output to a KRFBBuffer.
47 */
48 KRFBDecoder( KRFBConnection *con );
49 ~KRFBDecoder();
50
51 void setBuffer( KRFBBuffer *buf ) { this->buf = buf; };
52 void start();
53
54 int toKeySym( QKeyEvent *k );
55
56 //
57 // Client -> Server messages
58 //
59 void sendUpdateRequest( bool incremental );
60 void sendMouseEvent( QMouseEvent *e );
61 void sendKeyPressEvent( QKeyEvent *e );
62 void sendKeyReleaseEvent( QKeyEvent *e );
63 void sendCutEvent( const QString &text );
64
65protected:
66 //
67 // Initial format negotiation
68 //
69 void decidePixelFormat();
70 void sendPixelFormat();
71 void sendClientInit();
72 void sendAllowedEncodings();
73
74 //
75 // Rectange processing
76 //
77 void handleRawRect();
78 void handleCopyRect();
79 void handleRRERect();
80 void handleCoRRERect();
81 void handleHexTileRect();
82
83 void getRawRectChunk( int lines );
84
85protected slots:
86 void gotServerInit();
87 void gotDesktopName();
88 void gotUpdateHeader();
89 void gotRectHeader();
90 void gotRawRectChunk();
91 void gotCopyRectPos();
92 void gotServerCut();
93 void gotServerCutLength();
94 void gotServerCutText();
95 void gotBell();
96
97signals:
98 void error( const QString & );
99 void status( const QString & );
100
101private:
102 State currentState;
103
104 // Used to store the state we were in before a cut or bell msg
105 State oldState;
106
107 // The number of rects we're expecting
108 CARD16 noRects;
109
110 //
111 // Info about the current rect.
112 //
113 CARD16 x, y, w, h;
114 int lines;
115 CARD32 encoding;
116
117 CARD32 serverCutTextLen;
118
119 /** Where we draw the data (and the source of our events). */
120 KRFBBuffer *buf;
121 /** The connection to the server. */
122 KRFBConnection *con;
123
124 /** Info about the RFB server. */
125 KRFBServerInfo *info;
126 /** The pixel format we want. */
127 KRFBPixelFormat *format;
128
129 CARD8 buttonMask;
130};
131
132#endif // KRFBDECODER_H
133
134
diff --git a/noncore/comm/keypebble/krfblogin.cpp b/noncore/comm/keypebble/krfblogin.cpp
new file mode 100644
index 0000000..073ba0e
--- a/dev/null
+++ b/noncore/comm/keypebble/krfblogin.cpp
@@ -0,0 +1,255 @@
1#include <assert.h>
2
3
4extern "C" {
5#include "vncauth.h"
6}
7
8#include "krfblogin.h"
9#include "krfbconnection.h"
10#include <qtimer.h>
11
12// The length of the various messages (used to decide how many bytes to
13// wait for).
14const int ServerVersionLength = 12;
15const int ClientVersionLength = 12;
16const int AuthSchemeLength = 4;
17const int FailureReasonSizeLength = 4;
18const int ChallengeLength = 16;
19const int AuthResultLength = 4;
20
21// Authentication results
22enum AuthResult {
23 AuthOk,
24 AuthFailed,
25 AuthTooMany
26};
27
28typedef unsigned char CARD8;
29typedef unsigned short CARD16;
30typedef unsigned long CARD32;
31
32const int endianTest = 1;
33
34// Endian stuff
35#define Swap16IfLE(s) \
36 (*(char *)&endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
37
38#define Swap32IfLE(l) \
39 (*(char *)&endianTest ? ((((l) & 0xff000000) >> 24) | \
40 (((l) & 0x00ff0000) >> 8) | \
41 (((l) & 0x0000ff00) << 8) | \
42 (((l) & 0x000000ff) << 24)) : (l))
43
44KRFBLogin::KRFBLogin( KRFBConnection *con )
45 : QObject( con, "RFB login manager" )
46{
47 assert( con );
48 this->con = con;
49 currentState = AwaitingServerVersion;
50
51 connect( this, SIGNAL( error( const QString & ) ),
52 con, SIGNAL( error( const QString & ) ) );
53
54 connect( this, SIGNAL( passwordRequired( KRFBConnection * ) ),
55 con, SIGNAL( passwordRequired( KRFBConnection * ) ) );
56
57 qWarning( "Waiting for server version..." );
58
59 static QString statusMsg = tr( "Waiting for server version..." );
60 emit status( statusMsg );
61
62 // Kick off the state machine
63 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotServerVersion() ) );
64 con->waitForData( ServerVersionLength );
65}
66
67KRFBLogin::~KRFBLogin()
68{
69
70}
71
72KRFBLogin::State KRFBLogin::state() const
73{
74 return currentState;
75}
76
77void KRFBLogin::gotServerVersion()
78{
79 qWarning( "Got server version" );
80
81 disconnect( con, SIGNAL( gotEnoughData() ),
82 this, SLOT( gotServerVersion() ) );
83
84 // Read the server's version message
85 char serverVersion[ ServerVersionLength + 1 ];
86 con->read( serverVersion, ServerVersionLength );
87 serverVersion[ ServerVersionLength ] = '\0';
88
89 QCString rfbString( serverVersion, ServerVersionLength + 1 );
90 versionString = rfbString;
91
92 QRegExp regexp( "RFB [0-9][0-9][0-9]\\.[0-9][0-9][0-9]\n" );
93
94 if ( rfbString.find( regexp ) == -1 ) {
95 static QString msg = tr( "Error: Invalid server version, %1" ).arg( rfbString );
96
97 qWarning( msg );
98 emit error( msg );
99 currentState = Error;
100 return;
101 }
102
103 // Calculate the actual version number
104 serverMajor = (serverVersion[4] - '0') * 100
105 + (serverVersion[5] - '0') * 10
106 + (serverVersion[6] - '0');
107 serverMinor = (serverVersion[8] - '0') * 100
108 + (serverVersion[9] - '0') * 10
109 + (serverVersion[10] - '0');
110
111 qWarning("Server Version: %03d.%03d", serverMajor, serverMinor );
112
113 if ( serverMajor != 3 ) {
114 QString msg = tr( "Error: Unsupported server version, %1" )
115 .arg( rfbString );
116
117 qWarning( msg );
118 emit error( msg );
119 currentState = Error;
120 return;
121 }
122
123 if ( serverMinor != 3 ) {
124 qWarning( "Minor version mismatch: %d", serverMinor );
125 }
126
127 // Setup for the next state
128 sendClientVersion();
129
130 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthScheme() ) );
131 con->waitForData( AuthSchemeLength );
132}
133
134void KRFBLogin::gotAuthScheme()
135{
136 disconnect( con, SIGNAL( gotEnoughData() ),
137 this, SLOT( gotAuthScheme() ) );
138
139 // Got data
140 CARD32 scheme;
141 con->read( &scheme, AuthSchemeLength );
142 scheme = Swap32IfLE( scheme );
143
144 static QString statusMsgOk = tr( "Logged in" );
145
146 switch ( scheme ) {
147 case 0:
148 qWarning( "Failed" );
149 // Handle failure
150 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotFailureReasonSize() ) );
151 con->waitForData( FailureReasonSizeLength );
152 break;
153 case 1:
154 // Handle no auth
155 emit status( statusMsgOk );
156 con->gotRFBConnection();
157 break;
158 case 2:
159 // Handle VNC auth
160 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotChallenge() ) );
161 con->waitForData( ChallengeLength );
162 break;
163 default:
164 qWarning( "Unknown authentication scheme, 0x%08lx", scheme );
165 currentState = Error;
166 break;
167 };
168}
169
170void KRFBLogin::gotChallenge()
171{
172 disconnect( con, SIGNAL( gotEnoughData() ),
173 this, SLOT( gotChallenge() ) );
174
175 QTimer::singleShot( 0, this, SLOT(getPassword()) );
176}
177
178void KRFBLogin::getPassword()
179{
180 // Got data
181 CARD8 challenge[ ChallengeLength ];
182 con->read( challenge, ChallengeLength );
183
184 // Last chance to enter a password
185 if ( con->pass_.isNull() ) {
186 qWarning( "krfblogin needs a password" );
187 emit passwordRequired( con );
188 }
189
190 if ( con->pass_.isNull() ) {
191 QString msg = tr( "Error: This server requires a password, but none "
192 "has been specified.\n" );
193
194 emit error( msg );
195 return;
196 }
197
198 vncEncryptBytes( (unsigned char *) challenge, con->pass_.data() );
199 con->write( challenge, ChallengeLength );
200
201 connect( con, SIGNAL( gotEnoughData() ), SLOT( gotAuthResult() ) );
202 con->waitForData( AuthResultLength );
203}
204
205void KRFBLogin::gotFailureReasonSize()
206{
207 disconnect( con, SIGNAL( gotEnoughData() ), this,
208 SLOT( gotFailureReasonSize() ) );
209}
210
211void KRFBLogin::gotAuthResult()
212{
213 // Got data
214 disconnect( con, SIGNAL( gotEnoughData() ), this,
215 SLOT( gotAuthResult() ) );
216
217 long result;
218 con->read( &result, AuthResultLength );
219 result = Swap32IfLE( result );
220
221 qWarning( "Authentication Result is 0x%08lx", result );
222
223 static QString failed = tr( "Error: The password you specified was incorrect." );
224 static QString tooMany = tr( "Error: Too many invalid login attempts have been made\n"
225 "to this account, please try later." );
226
227 static QString statusMsgOk = tr( "Logged in" );
228 static QString statusMsgFailed = tr( "Login Failed" );
229 static QString statusMsgTooMany = tr( "Too many failures" );
230
231 switch( result ) {
232 case AuthOk:
233 emit status( statusMsgOk );
234 con->gotRFBConnection();
235 break;
236 case AuthFailed:
237 qWarning( "Dammit" );
238 emit status( statusMsgFailed );
239 emit error( failed );
240 break;
241 case AuthTooMany:
242 emit status( statusMsgTooMany );
243 emit error( tooMany );
244 break;
245 default:
246 qWarning( "Invalid authentication result, %lx", result );
247 break;
248 }
249}
250
251void KRFBLogin::sendClientVersion()
252{
253 qWarning( "Sending client version" );
254 con->write( (void*)"RFB 003.003\n", ClientVersionLength );
255}
diff --git a/noncore/comm/keypebble/krfblogin.h b/noncore/comm/keypebble/krfblogin.h
new file mode 100644
index 0000000..5208210
--- a/dev/null
+++ b/noncore/comm/keypebble/krfblogin.h
@@ -0,0 +1,62 @@
1// -*- c++ -*-
2
3#ifndef KRFBLOGIN_H
4#define KRFBLOGIN_H
5
6#include <qobject.h>
7
8class KRFBConnection;
9
10/**
11 * Handles logging into the RFB server.
12 *
13 * @version $Id$
14 * @author Richard Moore, rich@kde.org
15 */
16class KRFBLogin : QObject
17{
18 Q_OBJECT
19
20public:
21 enum State {
22 AwaitingServerVersion,
23 AwaitingAuthScheme,
24 AwaitingChallenge,
25 WaitingForResponse,
26 Authenticated,
27 Ready,
28 Failed,
29 Error
30 };
31
32 KRFBLogin( KRFBConnection *con );
33 ~KRFBLogin();
34
35 KRFBLogin::State state() const;
36
37protected:
38 void sendClientVersion();
39
40protected slots:
41 void getPassword();
42 void gotServerVersion();
43 void gotAuthScheme();
44 void gotChallenge();
45 void gotAuthResult();
46 void gotFailureReasonSize();
47
48signals:
49 void passwordRequired( KRFBConnection * );
50 void error( const QString & );
51 void status( const QString & );
52
53private:
54 KRFBConnection *con;
55 State currentState;
56 QCString versionString;
57 int serverMajor;
58 int serverMinor;
59};
60
61#endif // KRFBLOGIN_H
62
diff --git a/noncore/comm/keypebble/krfboptions.cpp b/noncore/comm/keypebble/krfboptions.cpp
new file mode 100644
index 0000000..9daf3f0
--- a/dev/null
+++ b/noncore/comm/keypebble/krfboptions.cpp
@@ -0,0 +1,52 @@
1#include <qpe/config.h>
2#include <qpe/qpeapplication.h>
3#include "krfboptions.h"
4
5KRFBOptions::KRFBOptions()
6{
7 Config config( "keypebble" );
8 readSettings( &config );
9}
10
11KRFBOptions::~KRFBOptions()
12{
13 Config config( "keypebble" );
14 writeSettings( &config );
15}
16
17void KRFBOptions::readSettings( Config *config )
18{
19 hexTile = config->readBoolEntry( "HexTile" );
20 corre = config->readBoolEntry( "CORRE" );
21 rre = config->readBoolEntry( "RRE" );
22 copyrect = config->readBoolEntry( "CopyRect", true );
23 colors256 = config->readBoolEntry( "Colors256" );
24 shared = config->readBoolEntry( "Shared" );
25 readOnly = config->readBoolEntry( "ReadOnly" );
26 updateRate = config->readNumEntry( "UpdateRate", 50 );
27}
28
29void KRFBOptions::writeSettings( Config *config )
30{
31 config->writeEntry( "HexTile", hexTile );
32 config->writeEntry( "CORRE", corre );
33 config->writeEntry( "RRE", rre );
34 config->writeEntry( "CopyRect", copyrect );
35 config->writeEntry( "Colors256", colors256 );
36 config->writeEntry( "Shared", shared );
37 config->writeEntry( "ReadOnly", readOnly );
38 config->writeEntry( "UpdateRate", updateRate );
39}
40
41int KRFBOptions::encodings()
42{
43 // Initially one because we always support raw encoding
44 int count = 1;
45
46 count += hexTile ? 1 : 0;
47 count += corre ? 1 : 0;
48 count += rre ? 1 : 0;
49 count += copyrect ? 1 : 0;
50
51 return count;
52}
diff --git a/noncore/comm/keypebble/krfboptions.h b/noncore/comm/keypebble/krfboptions.h
new file mode 100644
index 0000000..41cea35
--- a/dev/null
+++ b/noncore/comm/keypebble/krfboptions.h
@@ -0,0 +1,31 @@
1// -*- c++ -*-
2
3#ifndef KRFBOPTIONS_H
4#define KRFBOPTIONS_H
5
6class Config;
7
8class KRFBOptions
9{
10public:
11 KRFBOptions();
12 ~KRFBOptions();
13
14 int encodings();
15 void readSettings( Config *config );
16 void writeSettings( Config *config );
17
18 bool hexTile;
19 bool corre;
20 bool rre;
21 bool copyrect;
22
23 bool colors256;
24 bool shared;
25 bool readOnly;
26 bool deIconify;
27
28 int updateRate;
29};
30
31#endif // KRFBOPTIONS_H
diff --git a/noncore/comm/keypebble/krfbserverinfo.h b/noncore/comm/keypebble/krfbserverinfo.h
new file mode 100644
index 0000000..7449da9
--- a/dev/null
+++ b/noncore/comm/keypebble/krfbserverinfo.h
@@ -0,0 +1,42 @@
1// -*- c++ -*-
2
3#ifndef KRFBSERVERINFO_H
4#define KRFBSERVERINFO_H
5
6#include <qstring.h>
7
8typedef unsigned char CARD8;
9typedef unsigned short CARD16;
10typedef unsigned long CARD32;
11
12class KRFBPixelFormat
13{
14public:
15 CARD8 bpp;
16 CARD8 depth;
17 CARD8 bigEndian;
18 CARD8 trueColor;
19 CARD16 redMax;
20 CARD16 greenMax;
21 CARD16 blueMax;
22 CARD8 redShift;
23 CARD8 greenShift;
24 CARD8 blueShift;
25 CARD8 padding[3]; // 3 bytes padding
26};
27
28/**
29 * Information sent by the server in its init message.
30 */
31class KRFBServerInfo : public KRFBPixelFormat
32{
33public:
34 CARD16 width;
35 CARD16 height;
36 CARD32 nameLength;
37 QString name;
38};
39
40#endif // KRFBSERVERINFO_H
41
42
diff --git a/noncore/comm/keypebble/kvnc.cpp b/noncore/comm/keypebble/kvnc.cpp
new file mode 100644
index 0000000..bb18999
--- a/dev/null
+++ b/noncore/comm/keypebble/kvnc.cpp
@@ -0,0 +1,191 @@
1#include <qiconset.h>
2#include <qdialog.h>
3#include <qpixmap.h>
4#include <qdom.h>
5#include <qaction.h>
6#include <qpe/qpemenubar.h>
7#include <qstatusbar.h>
8#include <qpopupmenu.h>
9#include <qpushbutton.h>
10#include <qpe/qpetoolbar.h>
11#include <qtimer.h>
12#include <qmessagebox.h>
13#include <qpe/qpeapplication.h>
14#include <qpe/global.h>
15#include <assert.h>
16
17#include "kvnc.h"
18#include "krfbcanvas.h"
19#include "kvncoptionsdlg.h"
20#include "krfbconnection.h"
21
22
23/* XPM */
24static char * menu_xpm[] = {
25"12 12 5 1",
26 " c None",
27 ".c #000000",
28 "+c #FFFDAD",
29 "@c #FFFF00",
30 "#c #E5E100",
31" ",
32" ",
33" ......... ",
34" .+++++++. ",
35" .+@@@@#. ",
36" .+@@@#. ",
37" .+@@#. ",
38" .+@#. ",
39" .+#. ",
40" .+. ",
41" .. ",
42" "};
43
44const int StatusTextId = 0;
45
46KVNC::KVNC( const char *name ) : QMainWindow( 0, name )
47{
48 setCaption( tr("VNC Viewer") );
49 fullscreen = false;
50
51 canvas = new KRFBCanvas( this, "canvas" );
52 setCentralWidget( canvas );
53
54 connect( canvas->connection(), SIGNAL(statusChanged(const QString &)),
55 this, SLOT(statusMessage(const QString &)) );
56 connect( canvas->connection(), SIGNAL(error(const QString &)),
57 this, SLOT(error(const QString &)) );
58 connect( canvas->connection(), SIGNAL(connected()), this, SLOT(connected()) );
59 connect( canvas->connection(), SIGNAL(loggedIn()), this, SLOT(loggedIn()) );
60 connect( canvas->connection(), SIGNAL(disconnected()), this, SLOT(disconnected()) );
61
62 setupActions();
63
64 cornerButton = new QPushButton( this );
65 cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
66 connect( cornerButton, SIGNAL(pressed()), this, SLOT(showMenu()) );
67 canvas->setCornerWidget( cornerButton );
68
69 QTimer::singleShot( 0, canvas, SLOT(openConnection()) );
70}
71
72KVNC::~KVNC()
73{
74
75}
76
77void KVNC::openURL( const QUrl &url )
78{
79 canvas->openURL( url );
80}
81
82void KVNC::setupActions()
83{
84 cornerMenu = new QPopupMenu( this );
85
86 fullScreenAction = new QAction( tr("Full Screen"), QString::null, 0, 0 );
87 connect( fullScreenAction, SIGNAL(activated()),
88 this, SLOT( toggleFullScreen() ) );
89 fullScreenAction->addTo( cornerMenu );
90 fullScreenAction->setEnabled( false );
91
92 optionsAction = new QAction( tr("Settings"), QString::null, 0, 0 );
93 connect( optionsAction, SIGNAL(activated()), this, SLOT( showOptions() ) );
94 optionsAction->addTo( cornerMenu );
95
96 connectAction = new QAction( tr("Connect..."), QString::null, 0, 0 );
97 connect( connectAction, SIGNAL(activated()),
98 canvas, SLOT( openConnection() ) );
99 connectAction->addTo( cornerMenu );
100
101 disconnectAction = new QAction( tr("Disconnect"), QString::null, 0, 0 );
102 connect( disconnectAction, SIGNAL(activated()),
103 this, SLOT( closeConnection() ) );
104 disconnectAction->addTo( cornerMenu );
105 disconnectAction->setEnabled( false );
106}
107
108void KVNC::toggleFullScreen()
109{
110 if ( fullscreen ) {
111 canvas->releaseKeyboard();
112 canvas->reparent( this, 0, QPoint(0,0), false );
113 canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
114 setCentralWidget( canvas );
115 canvas->show();
116 fullScreenAction->setText( tr("Full Screen") );
117 } else {
118 canvas->setFrameStyle( QFrame::NoFrame );
119 canvas->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
120 QPoint(0,0),false);
121 canvas->resize(qApp->desktop()->width(), qApp->desktop()->height());
122 canvas->raise();
123 canvas->setFocus();
124 canvas->grabKeyboard();
125 canvas->show();
126
127 fullScreenAction->setText( tr("Stop Full Screen") );
128 }
129
130 fullscreen = !fullscreen;
131}
132
133void KVNC::closeConnection()
134{
135 if ( fullscreen )
136 toggleFullScreen();
137 canvas->closeConnection();
138}
139
140void KVNC::showMenu()
141{
142 QPoint pt = mapToGlobal(cornerButton->pos());
143 QSize s = cornerMenu->sizeHint();
144 pt.ry() -= s.height();
145 pt.rx() -= s.width();
146 cornerMenu->popup( pt );
147}
148
149void KVNC::connected()
150{
151 static QString msg = tr( "Connected to remote host" );
152 statusMessage( msg );
153 connectAction->setEnabled( false );
154 disconnectAction->setEnabled( true );
155 fullScreenAction->setEnabled( true );
156}
157
158void KVNC::loggedIn()
159{
160 static QString msg = tr( "Logged in to remote host" );
161 statusMessage( msg );
162}
163
164void KVNC::disconnected()
165{
166 static QString msg = tr( "Connection closed" );
167 statusMessage( msg );
168 connectAction->setEnabled( true );
169 disconnectAction->setEnabled( false );
170 fullScreenAction->setEnabled( false );
171}
172
173void KVNC::statusMessage( const QString &m )
174{
175 Global::statusMessage( m );
176}
177
178void KVNC::error( const QString &msg )
179{
180 statusMessage( msg );
181 QMessageBox::warning( this, tr("VNC Viewer"), msg );
182}
183
184void KVNC::showOptions()
185{
186 KVNCOptionsDlg *wdg = new KVNCOptionsDlg( canvas->connection()->options(), this );
187 wdg->showMaximized();
188 wdg->exec();
189 delete wdg;
190}
191
diff --git a/noncore/comm/keypebble/kvnc.h b/noncore/comm/keypebble/kvnc.h
new file mode 100644
index 0000000..92666c5
--- a/dev/null
+++ b/noncore/comm/keypebble/kvnc.h
@@ -0,0 +1,56 @@
1// -*- c++ -*-
2
3#ifndef KVNC_H
4#define KVNC_H
5
6#include <qmainwindow.h>
7#include <qurl.h>
8
9class QAction;
10class KRFBCanvas;
11class QPushButton;
12class QToolBar;
13
14/**
15 * Top level window for Keystone.
16 *
17 * @author Richard Moore, rich@kde.org
18 * @version $Id$
19 */
20class KVNC : public QMainWindow
21{
22 Q_OBJECT
23public:
24 KVNC( const char *name = 0 );
25 ~KVNC();
26
27public slots:
28 void toggleFullScreen();
29 void openURL( const QUrl & );
30 void closeConnection();
31 void showOptions();
32
33protected:
34 void setupActions();
35
36protected slots:
37 void showMenu();
38
39 void connected();
40 void loggedIn();
41 void disconnected();
42 void statusMessage( const QString & );
43 void error( const QString & );
44
45private:
46 bool fullscreen;
47 KRFBCanvas *canvas;
48 QPopupMenu *cornerMenu;
49 QPushButton *cornerButton;
50 QAction *fullScreenAction;
51 QAction *optionsAction;
52 QAction *disconnectAction;
53 QAction *connectAction;
54};
55
56#endif // KVNC_H
diff --git a/noncore/comm/keypebble/kvncconnectdlg.cpp b/noncore/comm/keypebble/kvncconnectdlg.cpp
new file mode 100644
index 0000000..467cebf
--- a/dev/null
+++ b/noncore/comm/keypebble/kvncconnectdlg.cpp
@@ -0,0 +1,79 @@
1#include <qstring.h>
2#include <qlayout.h>
3#include <qframe.h>
4#include <qspinbox.h>
5#include <qcombobox.h>
6#include <qlabel.h>
7#include <qfont.h>
8
9#include <assert.h>
10
11#include "krfbconnection.h"
12#include "kvncoptionsdlg.h"
13#include "kvncconnectdlg.h"
14
15
16KVNCConnectDlg::KVNCConnectDlg( KRFBConnection *con,
17 QWidget *parent, const char *name )
18 : QDialog( parent, name, true )
19{
20 setCaption( tr("Connect to VNC server") );
21 assert( con );
22 this->con = con;
23
24 QGridLayout *inner = new QGridLayout( this, 3, 2, 6 );
25
26 QLabel *label = new QLabel( tr("Host Name:"),
27 this , "hostLabel");
28 hostNameCombo = new QComboBox( true, this );
29 hostNameCombo->setInsertionPolicy( QComboBox::AtTop );
30 hostNameCombo->setMaxCount( 10 );
31 hostNameCombo->insertItem( "localhost" );
32 hostNameCombo->setFocus();
33
34 inner->addWidget( label, 0, 0 );
35 inner->addWidget( hostNameCombo, 0, 1 );
36
37 label = new QLabel( tr("Display Number:"), this, "displayNumber" );
38 displayNumberEdit = new QSpinBox( this );
39
40 inner->addWidget( label, 1, 0 );
41 inner->addWidget( displayNumberEdit, 1, 1 );
42
43 // if ( viewer->display() != -1 ) {
44 // displayNumberEdit->setValue( viewer->display() );
45 displayNumberEdit->setValue( 1 );
46 // }
47
48 label = new QLabel( tr("Password:"), this );
49 inner->addWidget( label, 2, 0 );
50
51 passwordEdit = new QLineEdit( this );
52 passwordEdit->setEchoMode( QLineEdit::Password );
53 inner->addWidget( passwordEdit, 2, 1 );
54
55 inner->setColStretch( 0, 0 );
56 inner->setColStretch( 1, 15 );
57}
58
59
60void KVNCConnectDlg::accept()
61{
62 int dis;
63 // viewer->setHost(hostNameCombo->currentText());
64 QString temp = displayNumberEdit->text();
65 if(temp.isEmpty())
66 dis = -1;
67 else
68 dis = temp.toUInt();
69 // viewer->setDisplay(dis);
70 QDialog::accept();
71}
72
73void KVNCConnectDlg::options()
74{
75 KVNCOptionsDlg *wdg = new KVNCOptionsDlg( con->options(), this );
76 wdg->exec();
77 delete wdg;
78}
79
diff --git a/noncore/comm/keypebble/kvncconnectdlg.h b/noncore/comm/keypebble/kvncconnectdlg.h
new file mode 100644
index 0000000..cf34aab
--- a/dev/null
+++ b/noncore/comm/keypebble/kvncconnectdlg.h
@@ -0,0 +1,39 @@
1// -*- c++ -*-
2
3#ifndef KVNCCONNECTDLG_H
4#define KVNCCONNECTDLG_H
5
6#include <qdialog.h>
7#include <qspinbox.h>
8#include <qcombobox.h>
9#include <qlineedit.h>
10#include <qurl.h>
11
12class KRFBConnection;
13
14class KVNCConnectDlg : public QDialog
15{
16 Q_OBJECT
17
18public:
19 KVNCConnectDlg( KRFBConnection *con,
20 QWidget *parent = 0, const char *name = 0 );
21
22 QString hostname() { return hostNameCombo->currentText(); };
23 int display() { return displayNumberEdit->value(); };
24 QString password() const { return passwordEdit->text(); }
25
26protected:
27 void accept();
28
29protected slots:
30 void options();
31
32private:
33 QComboBox *hostNameCombo;
34 QSpinBox *displayNumberEdit;
35 QLineEdit *passwordEdit;
36 KRFBConnection *con;
37};
38
39#endif // KVNCCONNECTDLG_H
diff --git a/noncore/comm/keypebble/kvncoptionsdlg.cpp b/noncore/comm/keypebble/kvncoptionsdlg.cpp
new file mode 100644
index 0000000..b9f57d1
--- a/dev/null
+++ b/noncore/comm/keypebble/kvncoptionsdlg.cpp
@@ -0,0 +1,53 @@
1#include <qframe.h>
2#include <qvbox.h>
3#include <qcheckbox.h>
4#include <qspinbox.h>
5#include <qlabel.h>
6#include <qlayout.h>
7#include <qwhatsthis.h>
8#include <qapplication.h>
9#include "krfboptions.h"
10
11#include "kvncoptionsdlg.h"
12
13KVNCOptionsDlg::KVNCOptionsDlg( KRFBOptions *options,
14 QWidget *parent, char *name, bool modal )
15 : VncOptionsBase( parent, name, modal )
16{
17 this->options = options;
18
19 hex->setChecked( options->hexTile );
20 corre->setChecked( options->corre );
21 rre->setChecked( options->rre );
22 copyRect->setChecked( options->copyrect );
23
24 // TODO
25 hex->setEnabled( false );
26 corre->setEnabled( false );
27 rre->setEnabled( false );
28 // /TODO
29
30 deIconify->setChecked( options->deIconify );
31 bit->setChecked( options->colors256 );
32 shared->setChecked( options->shared );
33 timeBox->setValue( options->updateRate );
34}
35
36KVNCOptionsDlg::~KVNCOptionsDlg()
37{
38}
39
40void KVNCOptionsDlg::accept()
41{
42 options->hexTile = hex->isChecked();
43 options->corre = corre->isChecked();
44 options->rre = rre->isChecked();
45 options->copyrect = copyRect->isChecked();
46 options->deIconify = deIconify->isChecked();
47 options->colors256 = bit->isChecked();
48 options->shared = shared->isChecked();
49 options->updateRate = timeBox->value();
50
51 QDialog::accept();
52}
53
diff --git a/noncore/comm/keypebble/kvncoptionsdlg.h b/noncore/comm/keypebble/kvncoptionsdlg.h
new file mode 100644
index 0000000..a166490
--- a/dev/null
+++ b/noncore/comm/keypebble/kvncoptionsdlg.h
@@ -0,0 +1,30 @@
1// -*- c++ -*-
2
3#ifndef KVNCOPTIONSDIALOG_H
4#define KVNCOPTIONSDIALOG_H
5
6#include "vncoptionsbase.h"
7
8class KRFBOptions;
9
10class KVNCOptionsDlg : public VncOptionsBase
11{
12Q_OBJECT
13
14public:
15 KVNCOptionsDlg( KRFBOptions *options,
16 QWidget *parent = 0, char *name = 0, bool modal = true );
17 ~KVNCOptionsDlg();
18
19protected:
20 void accept();
21
22private:
23 KRFBOptions *options;
24};
25
26#endif // KVNCOPTIONSDIALOG_H
27
28
29
30
diff --git a/noncore/comm/keypebble/main.cpp b/noncore/comm/keypebble/main.cpp
new file mode 100644
index 0000000..a32a368
--- a/dev/null
+++ b/noncore/comm/keypebble/main.cpp
@@ -0,0 +1,18 @@
1
2
3#include <qurl.h>
4#include <qpe/qpeapplication.h>
5#include "kvnc.h"
6
7int main( int argc, char **argv )
8{
9 QPEApplication app( argc, argv );
10 KVNC *view = new KVNC( "Keypebble" );
11 app.showMainWidget( view );
12
13 if ( argc > 1 )
14 view->openURL( QUrl(argv[1]) );
15
16 return app.exec();
17}
18
diff --git a/noncore/comm/keypebble/qpe-keypebble.control b/noncore/comm/keypebble/qpe-keypebble.control
new file mode 100644
index 0000000..75c1b9f
--- a/dev/null
+++ b/noncore/comm/keypebble/qpe-keypebble.control
@@ -0,0 +1,10 @@
1Files: bin/keypebble apps/Applications/keypebble.desktop pics/vnc.png
2Priority: optional
3Section: qpe/applications
4Maintainer: Martin Jones <mjones@trolltech.com>
5Architecture: arm
6Arch: iPAQ
7Version: $QPE_VERSION-2
8Depends: qpe-base ($QPE_VERSION)
9Description: VNC Viewer
10 Virtual Network Computing (VNC) viewer
diff --git a/noncore/comm/keypebble/vncauth.c b/noncore/comm/keypebble/vncauth.c
new file mode 100644
index 0000000..dc276bf
--- a/dev/null
+++ b/noncore/comm/keypebble/vncauth.c
@@ -0,0 +1,160 @@
1/*
2 * Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19
20/*
21 * vncauth.c - Functions for VNC password management and authentication.
22 */
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <sys/types.h>
28#include <sys/stat.h>
29#include <time.h>
30#include "vncauth.h"
31#include "d3des.h"
32
33
34/*
35 * We use a fixed key to store passwords, since we assume that our local
36 * file system is secure but nonetheless don't want to store passwords
37 * as plaintext.
38 */
39
40unsigned char fixedkey[8] = {23,82,107,6,35,78,88,7};
41
42
43/*
44 * Encrypt a password and store it in a file. Returns 0 if successful,
45 * 1 if the file could not be written.
46 */
47
48int
49vncEncryptAndStorePasswd(char *passwd, char *fname)
50{
51 FILE *fp;
52 int i;
53 unsigned char encryptedPasswd[8];
54
55 if ((fp = fopen(fname,"w")) == NULL) return 1;
56
57 chmod(fname, S_IRUSR|S_IWUSR);
58
59 /* pad password with nulls */
60
61 for (i = 0; i < 8; i++) {
62 if (i < strlen(passwd)) {
63 encryptedPasswd[i] = passwd[i];
64 } else {
65 encryptedPasswd[i] = 0;
66 }
67 }
68
69 /* Do encryption in-place - this way we overwrite our copy of the plaintext
70 password */
71
72 deskey(fixedkey, EN0);
73 des(encryptedPasswd, encryptedPasswd);
74
75 for (i = 0; i < 8; i++) {
76 putc(encryptedPasswd[i], fp);
77 }
78
79 fclose(fp);
80 return 0;
81}
82
83
84/*
85 * Decrypt a password from a file. Returns a pointer to a newly allocated
86 * string containing the password or a null pointer if the password could
87 * not be retrieved for some reason.
88 */
89
90char *
91vncDecryptPasswdFromFile(char *fname)
92{
93 FILE *fp;
94 int i, ch;
95 unsigned char *passwd = (unsigned char *)malloc(9);
96
97 if ((fp = fopen(fname,"r")) == NULL) return NULL;
98
99 for (i = 0; i < 8; i++) {
100 ch = getc(fp);
101 if (ch == EOF) {
102 fclose(fp);
103 return NULL;
104 }
105 passwd[i] = ch;
106 }
107
108 deskey(fixedkey, DE1);
109 des(passwd, passwd);
110
111 passwd[8] = 0;
112
113 return (char *)passwd;
114}
115
116
117/*
118 * Generate CHALLENGESIZE random bytes for use in challenge-response
119 * authentication.
120 */
121
122void
123vncRandomBytes(unsigned char *bytes)
124{
125 int i;
126 unsigned int seed = (unsigned int) time(0);
127
128 srandom(seed);
129 for (i = 0; i < CHALLENGESIZE; i++) {
130 bytes[i] = (unsigned char)(random() & 255);
131 }
132}
133
134
135/*
136 * Encrypt CHALLENGESIZE bytes in memory using a password.
137 */
138
139void
140vncEncryptBytes(unsigned char *bytes, char *passwd)
141{
142 unsigned char key[8];
143 int i;
144
145 /* key is simply password padded with nulls */
146
147 for (i = 0; i < 8; i++) {
148 if (i < strlen(passwd)) {
149 key[i] = passwd[i];
150 } else {
151 key[i] = 0;
152 }
153 }
154
155 deskey(key, EN0);
156
157 for (i = 0; i < CHALLENGESIZE; i += 8) {
158 des(bytes+i, bytes+i);
159 }
160}
diff --git a/noncore/comm/keypebble/vncauth.h b/noncore/comm/keypebble/vncauth.h
new file mode 100644
index 0000000..38b289e
--- a/dev/null
+++ b/noncore/comm/keypebble/vncauth.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
3 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19
20/*
21 * vncauth.h - describes the functions provided by the vncauth library.
22 */
23
24#define MAXPWLEN 8
25#define CHALLENGESIZE 16
26
27extern int vncEncryptAndStorePasswd(char *passwd, char *fname);
28extern char *vncDecryptPasswdFromFile(char *fname);
29extern void vncRandomBytes(unsigned char *bytes);
30extern void vncEncryptBytes(unsigned char *bytes, char *passwd);
diff --git a/noncore/comm/keypebble/vncoptionsbase.ui b/noncore/comm/keypebble/vncoptionsbase.ui
new file mode 100644
index 0000000..d049a79
--- a/dev/null
+++ b/noncore/comm/keypebble/vncoptionsbase.ui
@@ -0,0 +1,270 @@
1<!DOCTYPE UI><UI>
2<class>VncOptionsBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>VncOptionsBase</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>234</width>
15 <height>221</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>VNC Viewer Options</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <vbox>
26 <property stdset="1">
27 <name>margin</name>
28 <number>0</number>
29 </property>
30 <property stdset="1">
31 <name>spacing</name>
32 <number>6</number>
33 </property>
34 <widget>
35 <class>QTabWidget</class>
36 <property stdset="1">
37 <name>name</name>
38 <cstring>TabWidget3</cstring>
39 </property>
40 <widget>
41 <class>QWidget</class>
42 <property stdset="1">
43 <name>name</name>
44 <cstring>tab</cstring>
45 </property>
46 <attribute>
47 <name>title</name>
48 <string>Data Encoding</string>
49 </attribute>
50 <vbox>
51 <property stdset="1">
52 <name>margin</name>
53 <number>11</number>
54 </property>
55 <property stdset="1">
56 <name>spacing</name>
57 <number>6</number>
58 </property>
59 <widget>
60 <class>QLabel</class>
61 <property stdset="1">
62 <name>name</name>
63 <cstring>TextLabel1</cstring>
64 </property>
65 <property stdset="1">
66 <name>text</name>
67 <string>Check for screen updates every:</string>
68 </property>
69 </widget>
70 <widget>
71 <class>QLayoutWidget</class>
72 <property stdset="1">
73 <name>name</name>
74 <cstring>Layout2</cstring>
75 </property>
76 <hbox>
77 <property stdset="1">
78 <name>margin</name>
79 <number>0</number>
80 </property>
81 <property stdset="1">
82 <name>spacing</name>
83 <number>6</number>
84 </property>
85 <widget>
86 <class>QSpinBox</class>
87 <property stdset="1">
88 <name>name</name>
89 <cstring>timeBox</cstring>
90 </property>
91 <property stdset="1">
92 <name>maxValue</name>
93 <number>500</number>
94 </property>
95 <property stdset="1">
96 <name>minValue</name>
97 <number>1</number>
98 </property>
99 </widget>
100 <widget>
101 <class>QLabel</class>
102 <property stdset="1">
103 <name>name</name>
104 <cstring>TextLabel2</cstring>
105 </property>
106 <property stdset="1">
107 <name>text</name>
108 <string>Milliseconds</string>
109 </property>
110 </widget>
111 </hbox>
112 </widget>
113 <widget>
114 <class>QCheckBox</class>
115 <property stdset="1">
116 <name>name</name>
117 <cstring>bit</cstring>
118 </property>
119 <property stdset="1">
120 <name>text</name>
121 <string>Request 8-bit session</string>
122 </property>
123 </widget>
124 <widget>
125 <class>QCheckBox</class>
126 <property stdset="1">
127 <name>name</name>
128 <cstring>deIconify</cstring>
129 </property>
130 <property stdset="1">
131 <name>text</name>
132 <string>Raise on bell</string>
133 </property>
134 </widget>
135 <widget>
136 <class>QCheckBox</class>
137 <property stdset="1">
138 <name>name</name>
139 <cstring>shared</cstring>
140 </property>
141 <property stdset="1">
142 <name>text</name>
143 <string>Request shared session</string>
144 </property>
145 </widget>
146 <spacer>
147 <property>
148 <name>name</name>
149 <cstring>Spacer2</cstring>
150 </property>
151 <property stdset="1">
152 <name>orientation</name>
153 <enum>Vertical</enum>
154 </property>
155 <property stdset="1">
156 <name>sizeType</name>
157 <enum>Expanding</enum>
158 </property>
159 <property>
160 <name>sizeHint</name>
161 <size>
162 <width>20</width>
163 <height>20</height>
164 </size>
165 </property>
166 </spacer>
167 </vbox>
168 </widget>
169 <widget>
170 <class>QWidget</class>
171 <property stdset="1">
172 <name>name</name>
173 <cstring>tab</cstring>
174 </property>
175 <attribute>
176 <name>title</name>
177 <string>Connection</string>
178 </attribute>
179 <vbox>
180 <property stdset="1">
181 <name>margin</name>
182 <number>11</number>
183 </property>
184 <property stdset="1">
185 <name>spacing</name>
186 <number>6</number>
187 </property>
188 <widget>
189 <class>QCheckBox</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>hex</cstring>
193 </property>
194 <property stdset="1">
195 <name>enabled</name>
196 <bool>false</bool>
197 </property>
198 <property stdset="1">
199 <name>text</name>
200 <string>Hextile encoding</string>
201 </property>
202 </widget>
203 <widget>
204 <class>QCheckBox</class>
205 <property stdset="1">
206 <name>name</name>
207 <cstring>corre</cstring>
208 </property>
209 <property stdset="1">
210 <name>enabled</name>
211 <bool>false</bool>
212 </property>
213 <property stdset="1">
214 <name>text</name>
215 <string>CoRRE encoding</string>
216 </property>
217 </widget>
218 <widget>
219 <class>QCheckBox</class>
220 <property stdset="1">
221 <name>name</name>
222 <cstring>rre</cstring>
223 </property>
224 <property stdset="1">
225 <name>enabled</name>
226 <bool>false</bool>
227 </property>
228 <property stdset="1">
229 <name>text</name>
230 <string>RRE encoding</string>
231 </property>
232 </widget>
233 <widget>
234 <class>QCheckBox</class>
235 <property stdset="1">
236 <name>name</name>
237 <cstring>copyRect</cstring>
238 </property>
239 <property stdset="1">
240 <name>text</name>
241 <string>Copy rectangle encoding</string>
242 </property>
243 </widget>
244 <spacer>
245 <property>
246 <name>name</name>
247 <cstring>Spacer3</cstring>
248 </property>
249 <property stdset="1">
250 <name>orientation</name>
251 <enum>Vertical</enum>
252 </property>
253 <property stdset="1">
254 <name>sizeType</name>
255 <enum>Expanding</enum>
256 </property>
257 <property>
258 <name>sizeHint</name>
259 <size>
260 <width>20</width>
261 <height>20</height>
262 </size>
263 </property>
264 </spacer>
265 </vbox>
266 </widget>
267 </widget>
268 </vbox>
269</widget>
270</UI>