summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit38be0d13830efd2d98281c645c3a60afe05ffece (patch)
tree6ea73f3ec77f7d153333779883e8120f82820abe /src/plugins
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/accessible/accessible.pro6
-rw-r--r--src/plugins/accessible/qaccessiblebase.pri2
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.cpp2168
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.h293
-rw-r--r--src/plugins/accessible/widgets/main.cpp341
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.cpp678
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.h140
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp1667
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.h318
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.cpp991
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.h235
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp888
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.h193
-rw-r--r--src/plugins/accessible/widgets/widgets.pro20
-rw-r--r--src/plugins/bearer/bearer.pro19
-rw-r--r--src/plugins/bearer/connman/connman.pro21
-rw-r--r--src/plugins/bearer/connman/main.cpp93
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp594
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.h142
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp894
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux_p.h323
-rw-r--r--src/plugins/bearer/connman/qofonoservice_linux.cpp945
-rw-r--r--src/plugins/bearer/connman/qofonoservice_linux_p.h340
-rw-r--r--src/plugins/bearer/corewlan/corewlan.pro25
-rw-r--r--src/plugins/bearer/corewlan/main.cpp88
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h147
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm946
-rw-r--r--src/plugins/bearer/generic/generic.pro16
-rw-r--r--src/plugins/bearer/generic/main.cpp88
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp359
-rw-r--r--src/plugins/bearer/generic/qgenericengine.h96
-rw-r--r--src/plugins/bearer/icd/dbusdispatcher.cpp634
-rw-r--r--src/plugins/bearer/icd/dbusdispatcher.h111
-rw-r--r--src/plugins/bearer/icd/iapconf.cpp245
-rw-r--r--src/plugins/bearer/icd/iapconf.h74
-rw-r--r--src/plugins/bearer/icd/iapmonitor.cpp134
-rw-r--r--src/plugins/bearer/icd/iapmonitor.h68
-rw-r--r--src/plugins/bearer/icd/icd.pro33
-rw-r--r--src/plugins/bearer/icd/maemo_icd.cpp855
-rw-r--r--src/plugins/bearer/icd/maemo_icd.h174
-rw-r--r--src/plugins/bearer/icd/main.cpp88
-rw-r--r--src/plugins/bearer/icd/proxyconf.cpp422
-rw-r--r--src/plugins/bearer/icd/proxyconf.h74
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp1126
-rw-r--r--src/plugins/bearer/icd/qicdengine.h177
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp1072
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.h229
-rw-r--r--src/plugins/bearer/icd/wlan-utils.h110
-rw-r--r--src/plugins/bearer/nativewifi/main.cpp143
-rw-r--r--src/plugins/bearer/nativewifi/nativewifi.pro17
-rw-r--r--src/plugins/bearer/nativewifi/platformdefs.h326
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp611
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.h108
-rw-r--r--src/plugins/bearer/networkmanager/main.cpp95
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.pro20
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp911
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h142
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp931
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h448
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.cpp130
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.h79
-rw-r--r--src/plugins/bearer/nla/main.cpp84
-rw-r--r--src/plugins/bearer/nla/nla.pro23
-rw-r--r--src/plugins/bearer/nla/qnlaengine.cpp650
-rw-r--r--src/plugins/bearer/nla/qnlaengine.h112
-rw-r--r--src/plugins/bearer/platformdefs_win.h141
-rw-r--r--src/plugins/bearer/qbearerengine_impl.h85
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp421
-rw-r--r--src/plugins/bearer/qnetworksession_impl.h132
-rw-r--r--src/plugins/bearer/symbian/3_1/3_1.pro9
-rw-r--r--src/plugins/bearer/symbian/3_2/3_2.pro17
-rw-r--r--src/plugins/bearer/symbian/main.cpp88
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.cpp1549
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.h237
-rw-r--r--src/plugins/bearer/symbian/symbian.pri32
-rw-r--r--src/plugins/bearer/symbian/symbian.pro8
-rw-r--r--src/plugins/bearer/symbian/symbian_3/symbian_3.pro21
-rw-r--r--src/plugins/bearer/symbian/symbianengine.cpp1409
-rw-r--r--src/plugins/bearer/symbian/symbianengine.h246
-rw-r--r--src/plugins/codecs/cn/cn.pro16
-rw-r--r--src/plugins/codecs/cn/main.cpp145
-rw-r--r--src/plugins/codecs/cn/qgb18030codec.cpp9265
-rw-r--r--src/plugins/codecs/cn/qgb18030codec.h159
-rw-r--r--src/plugins/codecs/codecs.pro4
-rw-r--r--src/plugins/codecs/jp/jp.pro27
-rw-r--r--src/plugins/codecs/jp/main.cpp149
-rw-r--r--src/plugins/codecs/jp/qeucjpcodec.cpp261
-rw-r--r--src/plugins/codecs/jp/qeucjpcodec.h106
-rw-r--r--src/plugins/codecs/jp/qfontjpcodec.cpp145
-rw-r--r--src/plugins/codecs/jp/qfontjpcodec.h93
-rw-r--r--src/plugins/codecs/jp/qjiscodec.cpp367
-rw-r--r--src/plugins/codecs/jp/qjiscodec.h106
-rw-r--r--src/plugins/codecs/jp/qjpunicode.cpp10700
-rw-r--r--src/plugins/codecs/jp/qjpunicode.h174
-rw-r--r--src/plugins/codecs/jp/qsjiscodec.cpp227
-rw-r--r--src/plugins/codecs/jp/qsjiscodec.h106
-rw-r--r--src/plugins/codecs/kr/cp949codetbl.h632
-rw-r--r--src/plugins/codecs/kr/kr.pro20
-rw-r--r--src/plugins/codecs/kr/main.cpp131
-rw-r--r--src/plugins/codecs/kr/qeuckrcodec.cpp3571
-rw-r--r--src/plugins/codecs/kr/qeuckrcodec.h129
-rw-r--r--src/plugins/codecs/tw/main.cpp138
-rw-r--r--src/plugins/codecs/tw/qbig5codec.cpp12788
-rw-r--r--src/plugins/codecs/tw/qbig5codec.h124
-rw-r--r--src/plugins/codecs/tw/tw.pro16
-rw-r--r--src/plugins/decorations/decorations.pro4
-rw-r--r--src/plugins/decorations/default/default.pro10
-rw-r--r--src/plugins/decorations/default/main.cpp76
-rw-r--r--src/plugins/decorations/styled/main.cpp77
-rw-r--r--src/plugins/decorations/styled/styled.pro13
-rw-r--r--src/plugins/decorations/windows/main.cpp76
-rw-r--r--src/plugins/decorations/windows/windows.pro10
-rw-r--r--src/plugins/generic/linuxinput/linuxinput.pro18
-rw-r--r--src/plugins/generic/linuxinput/main.cpp80
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.cpp557
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.h111
-rw-r--r--src/plugins/generic/tslib/main.cpp78
-rw-r--r--src/plugins/generic/tslib/qtslib.cpp144
-rw-r--r--src/plugins/generic/tslib/qtslib.h77
-rw-r--r--src/plugins/generic/tslib/tslib.pro13
-rw-r--r--src/plugins/gfxdrivers/ahi/ahi.pro14
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp598
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahi_qws.h84
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp74
-rw-r--r--src/plugins/gfxdrivers/directfb/directfb.pro15
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp436
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h74
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp294
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.h75
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp221
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h108
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp1430
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h123
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp588
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h105
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp1819
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h303
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp78
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp506
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h129
-rw-r--r--src/plugins/gfxdrivers/eglnullws/README48
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullws.pro18
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp181
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h69
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp66
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h47
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp84
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h63
-rw-r--r--src/plugins/gfxdrivers/gfxdrivers.pro10
-rw-r--r--src/plugins/gfxdrivers/linuxfb/linuxfb.pro14
-rw-r--r--src/plugins/gfxdrivers/linuxfb/main.cpp79
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro26
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c830
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h169
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h132
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c402
-rw-r--r--src/plugins/gfxdrivers/powervr/README66
-rw-r--r--src/plugins/gfxdrivers/powervr/powervr.pri2
-rw-r--r--src/plugins/gfxdrivers/powervr/powervr.pro3
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp351
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h99
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro27
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp74
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp273
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h85
-rw-r--r--src/plugins/gfxdrivers/qvfb/main.cpp82
-rw-r--r--src/plugins/gfxdrivers/qvfb/qvfb.pro19
-rw-r--r--src/plugins/gfxdrivers/transformed/main.cpp84
-rw-r--r--src/plugins/gfxdrivers/transformed/transformed.pro13
-rw-r--r--src/plugins/gfxdrivers/vnc/main.cpp86
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_p.h524
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp2338
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h88
-rw-r--r--src/plugins/gfxdrivers/vnc/vnc.pro16
-rw-r--r--src/plugins/graphicssystems/graphicssystems.pro15
-rw-r--r--src/plugins/graphicssystems/meego/dithering.cpp266
-rw-r--r--src/plugins/graphicssystems/meego/meego.pro13
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.cpp213
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.h125
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp534
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h127
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp58
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h54
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp323
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h78
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp224
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.h74
-rw-r--r--src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp60
-rw-r--r--src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h55
-rw-r--r--src/plugins/graphicssystems/opengl/main.cpp95
-rw-r--r--src/plugins/graphicssystems/opengl/opengl.pro13
-rw-r--r--src/plugins/graphicssystems/openvg/main.cpp71
-rw-r--r--src/plugins/graphicssystems/openvg/openvg.pro14
-rw-r--r--src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp88
-rw-r--r--src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h73
-rw-r--r--src/plugins/graphicssystems/shivavg/README8
-rw-r--r--src/plugins/graphicssystems/shivavg/main.cpp71
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavg.pro12
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp62
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h60
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp358
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h76
-rw-r--r--src/plugins/graphicssystems/trace/main.cpp69
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp153
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h71
-rw-r--r--src/plugins/graphicssystems/trace/trace.pro13
-rw-r--r--src/plugins/imageformats/gif/gif.pro11
-rw-r--r--src/plugins/imageformats/gif/main.cpp98
-rw-r--r--src/plugins/imageformats/ico/ico.pro14
-rw-r--r--src/plugins/imageformats/ico/main.cpp96
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp899
-rw-r--r--src/plugins/imageformats/ico/qicohandler.h79
-rw-r--r--src/plugins/imageformats/imageformats.pro8
-rw-r--r--src/plugins/imageformats/jpeg/jpeg.pro11
-rw-r--r--src/plugins/imageformats/jpeg/main.cpp97
-rw-r--r--src/plugins/imageformats/mng/main.cpp98
-rw-r--r--src/plugins/imageformats/mng/mng.pro17
-rw-r--r--src/plugins/imageformats/tiff/main.cpp97
-rw-r--r--src/plugins/imageformats/tiff/tiff.pro13
-rw-r--r--src/plugins/inputmethods/imsw-multi/imsw-multi.pro13
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontext.cpp212
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h117
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.cpp111
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h85
-rw-r--r--src/plugins/inputmethods/inputmethods.pro3
-rw-r--r--src/plugins/kbddrivers/kbddrivers.pro2
-rw-r--r--src/plugins/kbddrivers/linuxinput/linuxinput.pro14
-rw-r--r--src/plugins/kbddrivers/linuxinput/main.cpp77
-rw-r--r--src/plugins/mousedrivers/linuxtp/linuxtp.pro14
-rw-r--r--src/plugins/mousedrivers/linuxtp/main.cpp76
-rw-r--r--src/plugins/mousedrivers/mousedrivers.pro5
-rw-r--r--src/plugins/mousedrivers/pc/main.cpp81
-rw-r--r--src/plugins/mousedrivers/pc/pc.pro14
-rw-r--r--src/plugins/mousedrivers/tslib/main.cpp77
-rw-r--r--src/plugins/mousedrivers/tslib/tslib.pro16
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro29
-rw-r--r--src/plugins/platforms/cocoa/main.mm74
-rw-r--r--src/plugins/platforms/cocoa/qcocoaautoreleasepool.h57
-rw-r--r--src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm52
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.h65
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm112
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h99
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm132
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h75
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm110
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowsurface.h73
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowsurface.mm103
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h79
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm211
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h61
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm73
-rw-r--r--src/plugins/platforms/directfb/directfb.pro35
-rw-r--r--src/plugins/platforms/directfb/main.cpp72
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.cpp155
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.h76
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.cpp376
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.h84
-rw-r--r--src/plugins/platforms/directfb/qdirectfbcursor.cpp80
-rw-r--r--src/plugins/platforms/directfb/qdirectfbcursor.h63
-rw-r--r--src/plugins/platforms/directfb/qdirectfbglcontext.cpp101
-rw-r--r--src/plugins/platforms/directfb/qdirectfbglcontext.h69
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.cpp208
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.h86
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.cpp144
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.h104
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindow.cpp191
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindow.h79
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp141
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindowsurface.h77
-rw-r--r--src/plugins/platforms/eglconvenience/eglconvenience.pri7
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.cpp324
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h60
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp157
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.h71
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp184
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.h53
-rw-r--r--src/plugins/platforms/eglconvenience/xlibeglintegration.pri7
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pro31
-rw-r--r--src/plugins/platforms/eglfs/main.cpp72
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp109
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h77
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.cpp244
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h80
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp87
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h68
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindowsurface.cpp101
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindowsurface.h67
-rw-r--r--src/plugins/platforms/externalplugin.pri29
-rw-r--r--src/plugins/platforms/fb_base/fb_base.cpp507
-rw-r--r--src/plugins/platforms/fb_base/fb_base.h210
-rw-r--r--src/plugins/platforms/fb_base/fb_base.pri2
-rw-r--r--src/plugins/platforms/fb_base/fb_base.pro23
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/basicunix.pri86
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp328
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h67
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri12
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp601
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h56
-rw-r--r--src/plugins/platforms/fontdatabases/genericunix/genericunix.pri10
-rw-r--r--src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h53
-rw-r--r--src/plugins/platforms/glxconvenience/glxconvenience.pri7
-rw-r--r--src/plugins/platforms/glxconvenience/qglxconvenience.cpp243
-rw-r--r--src/plugins/platforms/glxconvenience/qglxconvenience.h56
-rw-r--r--src/plugins/platforms/linuxfb/linuxfb.pro13
-rw-r--r--src/plugins/platforms/linuxfb/main.cpp72
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp875
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.h135
-rw-r--r--src/plugins/platforms/minimal/main.cpp73
-rw-r--r--src/plugins/platforms/minimal/minimal.pro13
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp82
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h86
-rw-r--r--src/plugins/platforms/minimal/qminimalwindowsurface.cpp86
-rw-r--r--src/plugins/platforms/minimal/qminimalwindowsurface.h67
-rw-r--r--src/plugins/platforms/openkode/main.cpp72
-rw-r--r--src/plugins/platforms/openkode/openkode.pro42
-rw-r--r--src/plugins/platforms/openkode/openkodekeytranslator.h244
-rw-r--r--src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp128
-rw-r--r--src/plugins/platforms/openkode/qopenkodeeventloopintegration.h71
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.cpp247
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.h120
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.cpp315
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.h89
-rw-r--r--src/plugins/platforms/openkode/resources.qrc6
-rw-r--r--src/plugins/platforms/openkode/shaders/frag.glslf49
-rw-r--r--src/plugins/platforms/openkode/shaders/vert.glslv55
-rw-r--r--src/plugins/platforms/openvglite/main.cpp71
-rw-r--r--src/plugins/platforms/openvglite/openvglite.pro12
-rw-r--r--src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp193
-rw-r--r--src/plugins/platforms/openvglite/qgraphicssystem_vglite.h93
-rw-r--r--src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp131
-rw-r--r--src/plugins/platforms/openvglite/qwindowsurface_vglite.h91
-rw-r--r--src/plugins/platforms/platforms.pro8
-rw-r--r--src/plugins/platforms/qvfb/main.cpp73
-rw-r--r--src/plugins/platforms/qvfb/qvfb.pro13
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.cpp448
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.h100
-rw-r--r--src/plugins/platforms/qvfb/qvfbwindowsurface.cpp108
-rw-r--r--src/plugins/platforms/qvfb/qvfbwindowsurface.h80
-rw-r--r--src/plugins/platforms/uikit/README45
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/main.mm78
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qml/main.qml112
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp110
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp196
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h80
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist28
-rwxr-xr-xsrc/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj491
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch8
-rw-r--r--src/plugins/platforms/uikit/main.mm74
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.h72
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.mm179
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.h72
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.mm104
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.h75
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.mm84
-rw-r--r--src/plugins/platforms/uikit/quikitsoftwareinputhandler.h61
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.h122
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.mm375
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.h64
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.mm96
-rw-r--r--src/plugins/platforms/uikit/uikit.pro27
-rw-r--r--src/plugins/platforms/vnc/main.cpp73
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.cpp156
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.h76
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp251
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.h110
-rw-r--r--src/plugins/platforms/vnc/qvncserver.cpp1935
-rw-r--r--src/plugins/platforms/vnc/qvncserver.h533
-rw-r--r--src/plugins/platforms/vnc/vnc.pro22
-rw-r--r--src/plugins/platforms/wayland/gl_integration/gl_integration.pri57
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp52
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h62
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp184
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h69
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp174
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h80
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp112
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h82
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp76
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h66
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri14
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp163
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h79
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp97
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h80
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp73
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h65
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri12
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h57
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp95
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h73
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp112
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h71
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp126
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h80
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri12
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp169
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h82
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp139
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h98
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp77
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h65
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri15
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp150
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h85
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp126
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h93
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp77
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h65
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri13
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp59
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h62
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h145
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c59
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri9
-rw-r--r--src/plugins/platforms/wayland/main.cpp75
-rw-r--r--src/plugins/platforms/wayland/qwaylandbuffer.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp191
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp270
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h134
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp337
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.h101
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp127
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h76
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.cpp107
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.h77
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.cpp145
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.h83
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.cpp71
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.h58
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp158
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h93
-rw-r--r--src/plugins/platforms/wayland/wayland.pro39
-rw-r--r--src/plugins/platforms/xcb/README3
-rw-r--r--src/plugins/platforms/xcb/main.cpp72
-rw-r--r--src/plugins/platforms/xcb/qdri2context.cpp271
-rw-r--r--src/plugins/platforms/xcb/qdri2context.h77
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp154
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h78
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp780
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h331
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp151
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h83
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp973
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h82
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp185
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h75
-rw-r--r--src/plugins/platforms/xcb/qxcbobject.h62
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp134
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h80
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp683
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h108
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp258
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.h72
-rw-r--r--src/plugins/platforms/xcb/xcb.pro70
-rw-r--r--src/plugins/platforms/xlib/main.cpp79
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.cpp160
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.h85
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.cpp677
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.h94
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.cpp200
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.h68
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.cpp78
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.h63
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.cpp173
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.h90
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.cpp1001
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.h76
-rw-r--r--src/plugins/platforms/xlib/qxlibmime.cpp322
-rw-r--r--src/plugins/platforms/xlib/qxlibmime.h67
-rw-r--r--src/plugins/platforms/xlib/qxlibnativeinterface.cpp133
-rw-r--r--src/plugins/platforms/xlib/qxlibnativeinterface.h75
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.cpp488
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.h112
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.cpp512
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.h413
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.cpp737
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.h145
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.cpp224
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.h86
-rw-r--r--src/plugins/platforms/xlib/xlib.pro62
-rw-r--r--src/plugins/plugins.pro17
-rw-r--r--src/plugins/qpluginbase.pri41
-rw-r--r--src/plugins/s60/3_1/3_1.pro9
-rw-r--r--src/plugins/s60/3_2/3_2.pro23
-rw-r--r--src/plugins/s60/5_0/5_0.pro23
-rw-r--r--src/plugins/s60/bwins/qts60pluginu.def8
-rw-r--r--src/plugins/s60/eabi/qts60pluginu.def8
-rw-r--r--src/plugins/s60/s60.pro11
-rw-r--r--src/plugins/s60/s60pluginbase.pri23
-rw-r--r--src/plugins/s60/src/qcoreapplication_3_1.cpp48
-rw-r--r--src/plugins/s60/src/qcoreapplication_3_2.cpp48
-rw-r--r--src/plugins/s60/src/qdesktopservices_3_1.cpp49
-rw-r--r--src/plugins/s60/src/qdesktopservices_3_2.cpp80
-rw-r--r--src/plugins/s60/src/qlocale_3_1.cpp148
-rw-r--r--src/plugins/s60/src/qlocale_3_2.cpp66
-rw-r--r--src/plugins/sqldrivers/README5
-rw-r--r--src/plugins/sqldrivers/db2/README6
-rw-r--r--src/plugins/sqldrivers/db2/db2.pro6
-rw-r--r--src/plugins/sqldrivers/db2/main.cpp81
-rw-r--r--src/plugins/sqldrivers/ibase/ibase.pro6
-rw-r--r--src/plugins/sqldrivers/ibase/main.cpp81
-rw-r--r--src/plugins/sqldrivers/mysql/README6
-rw-r--r--src/plugins/sqldrivers/mysql/main.cpp82
-rw-r--r--src/plugins/sqldrivers/mysql/mysql.pro6
-rw-r--r--src/plugins/sqldrivers/oci/README6
-rw-r--r--src/plugins/sqldrivers/oci/main.cpp82
-rw-r--r--src/plugins/sqldrivers/oci/oci.pro6
-rw-r--r--src/plugins/sqldrivers/odbc/README6
-rw-r--r--src/plugins/sqldrivers/odbc/main.cpp82
-rw-r--r--src/plugins/sqldrivers/odbc/odbc.pro6
-rw-r--r--src/plugins/sqldrivers/psql/README6
-rw-r--r--src/plugins/sqldrivers/psql/main.cpp82
-rw-r--r--src/plugins/sqldrivers/psql/psql.pro6
-rw-r--r--src/plugins/sqldrivers/qsqldriverbase.pri8
-rw-r--r--src/plugins/sqldrivers/sqldrivers.pro13
-rw-r--r--src/plugins/sqldrivers/sqlite/README6
-rw-r--r--src/plugins/sqldrivers/sqlite/smain.cpp81
-rw-r--r--src/plugins/sqldrivers/sqlite/sqlite.pro8
-rw-r--r--src/plugins/sqldrivers/sqlite2/README6
-rw-r--r--src/plugins/sqldrivers/sqlite2/smain.cpp81
-rw-r--r--src/plugins/sqldrivers/sqlite2/sqlite2.pro6
-rw-r--r--src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zipbin0 -> 3119273 bytes
-rw-r--r--src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri52
-rw-r--r--src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro9
-rw-r--r--src/plugins/sqldrivers/tds/README6
-rw-r--r--src/plugins/sqldrivers/tds/main.cpp89
-rw-r--r--src/plugins/sqldrivers/tds/tds.pro6
528 files changed, 124707 insertions, 0 deletions
diff --git a/src/plugins/accessible/accessible.pro b/src/plugins/accessible/accessible.pro
new file mode 100644
index 0000000000..a7caf07106
--- /dev/null
+++ b/src/plugins/accessible/accessible.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+
+contains(QT_CONFIG, accessibility) {
+ SUBDIRS += widgets
+ contains(QT_CONFIG, qt3support):SUBDIRS += compat
+}
diff --git a/src/plugins/accessible/qaccessiblebase.pri b/src/plugins/accessible/qaccessiblebase.pri
new file mode 100644
index 0000000000..95c1fad13a
--- /dev/null
+++ b/src/plugins/accessible/qaccessiblebase.pri
@@ -0,0 +1,2 @@
+target.path += $$[QT_INSTALL_PLUGINS]/accessible
+INSTALLS += target
diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp
new file mode 100644
index 0000000000..e6384133c0
--- /dev/null
+++ b/src/plugins/accessible/widgets/complexwidgets.cpp
@@ -0,0 +1,2168 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "complexwidgets.h"
+
+#include <qapplication.h>
+#include <qabstractbutton.h>
+#include <qevent.h>
+#include <qheaderview.h>
+#include <qtabbar.h>
+#include <qcombobox.h>
+#include <qlistview.h>
+#include <qtableview.h>
+#include <qlineedit.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qtreeview.h>
+#include <private/qtabbar_p.h>
+#include <QAbstractScrollArea>
+#include <QScrollArea>
+#include <QScrollBar>
+#include <QDebug>
+
+#ifndef QT_NO_ACCESSIBILITY
+
+QT_BEGIN_NAMESPACE
+
+QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
+
+#ifndef QT_NO_ITEMVIEWS
+/*
+The MSDN article "Exposing Data Tables through Microsoft Active Accessibility" explains
+how data tables should be exposed. Url: http://msdn2.microsoft.com/en-us/library/ms971325.aspx
+Basically, the model is like this:
+
+ROLE_SYSTEM_TABLE
+ |- ROLE_SYSTEM_ROW
+ | |- ROLE_SYSTEM_ROWHEADER
+ | |- ROLE_SYSTEM_COLUMNHEADER
+ | |- ROLE_SYSTEM_COLUMNHEADER
+ | |- ROLE_SYSTEM_COLUMNHEADER
+ | '- ..
+ |- ROLE_SYSTEM_ROW
+ | |- ROLE_SYSTEM_ROWHEADER
+ | |- ROLE_SYSTEM_CELL
+ | |- ROLE_SYSTEM_CELL
+ | |- ROLE_SYSTEM_CELL
+ | '- ..
+ |- ROLE_SYSTEM_ROW
+ | |- ROLE_SYSTEM_ROWHEADER
+ | |- ROLE_SYSTEM_CELL
+ | |- ROLE_SYSTEM_CELL
+ | |- ROLE_SYSTEM_CELL
+ | '- ..
+ '- ..
+
+The headers of QTreeView is also represented like this.
+*/
+QAccessibleItemRow::QAccessibleItemRow(QAbstractItemView *aView, const QModelIndex &index, bool isHeader)
+ : row(index), view(aView), m_header(isHeader)
+{
+}
+
+QHeaderView *QAccessibleItemRow::horizontalHeader() const
+{
+ QHeaderView *header = 0;
+ if (m_header) {
+ if (false) {
+#ifndef QT_NO_TABLEVIEW
+ } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
+ header = tv->horizontalHeader();
+#endif
+#ifndef QT_NO_TREEVIEW
+ } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
+ header = tv->header();
+#endif
+ }
+ }
+ return header;
+}
+
+QHeaderView *QAccessibleItemRow::verticalHeader() const
+{
+ QHeaderView *header = 0;
+#ifndef QT_NO_TABLEVIEW
+ if (const QTableView *tv = qobject_cast<const QTableView*>(view))
+ header = tv->verticalHeader();
+#endif
+ return header;
+}
+
+int QAccessibleItemRow::logicalFromChild(QHeaderView *header, int child) const
+{
+ int logical = -1;
+ if (header->sectionsHidden()) {
+ int kid = 0;
+ for (int i = 0; i < header->count(); ++i) {
+ if (!header->isSectionHidden(i))
+ ++kid;
+ if (kid == child) {
+ logical = i;
+ break;
+ }
+ }
+ } else {
+ logical = child - 1;
+ }
+ return logical;
+}
+
+QRect QAccessibleItemRow::rect(int child) const
+{
+ QRect r;
+ if (view && view->isVisible()) {
+ if (QHeaderView *header = horizontalHeader()) {
+ if (!child) {
+ r = header->rect();
+ } else {
+ if (QHeaderView *vheader = verticalHeader()) {
+ if (child == 1) {
+ int w = vheader->width();
+ int h = header->height();
+ r.setRect(0, 0, w, h);
+ }
+ --child;
+ }
+ if (child) {
+ int logical = logicalFromChild(header, child);
+ int w = header->sectionSize(logical);
+ r.setRect(header->sectionViewportPosition(logical), 0, w, header->height());
+ r.translate(header->mapTo(view, QPoint(0, 0)));
+ }
+ }
+ } else if (row.isValid()) {
+ if (!child) {
+ QModelIndex parent = row.parent();
+ const int colCount = row.model()->columnCount(parent);
+ for (int i = 0; i < colCount; ++i)
+ r |= view->visualRect(row.model()->index(row.row(), i, parent));
+ r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
+
+ if (const QHeaderView *vheader = verticalHeader()) { // include the section of the vertical header
+ QRect re;
+ int logicalRow = row.row();
+ int h = vheader->sectionSize(logicalRow);
+ re.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h);
+ re.translate(vheader->mapTo(view, QPoint(0, 0)));
+ r |= re;
+ }
+ } else {
+ if (QHeaderView *vheader = verticalHeader()) {
+ if (child == 1) {
+ int logicalRow = row.row();
+ int h = vheader->sectionSize(logicalRow);
+ r.setRect(0, vheader->sectionViewportPosition(logicalRow), vheader->width(), h);
+ r.translate(vheader->mapTo(view, QPoint(0, 0)));
+ }
+ --child;
+ }
+ if (child) {
+ r = view->visualRect(childIndex(child));
+ r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
+ }
+ }
+ }
+ }
+ if (!r.isNull())
+ r.translate(view->mapToGlobal(QPoint(0, 0)));
+
+ return r;
+}
+
+int QAccessibleItemRow::treeLevel() const
+{
+ int level = 0;
+ QModelIndex idx = row;
+ while (idx.isValid()) {
+ idx = idx.parent();
+ ++level;
+ }
+ return level;
+}
+
+QString QAccessibleItemRow::text_helper(int child) const
+{
+ QString value;
+ if (m_header) {
+ if (!child)
+ return QString();
+ if (verticalHeader()) {
+ if (child == 1)
+ return QString();
+ --child;
+ }
+ QHeaderView *header = horizontalHeader();
+ int logical = logicalFromChild(header, child);
+ value = view->model()->headerData(logical, Qt::Horizontal, Qt::AccessibleTextRole).toString();
+ if (value.isEmpty())
+ value = view->model()->headerData(logical, Qt::Horizontal).toString();
+ return value;
+ } else {
+ if (!child) { // for one-column views (i.e. QListView)
+ if (children().count() >= 1)
+ child = 1;
+ else
+ return QString();
+ }
+ if (verticalHeader()) {
+ if (child == 1) {
+ int logical = row.row();
+ value = view->model()->headerData(logical, Qt::Vertical, Qt::AccessibleTextRole).toString();
+ if (value.isEmpty())
+ value = view->model()->headerData(logical, Qt::Vertical).toString();
+ return value;
+ } else {
+ --child;
+ }
+ }
+ }
+ if (value.isEmpty()) {
+ QModelIndex idx = childIndex(child);
+ if (idx.isValid()) {
+ value = idx.model()->data(idx, Qt::AccessibleTextRole).toString();
+ if (value.isEmpty())
+ value = idx.model()->data(idx, Qt::DisplayRole).toString();
+ }
+ }
+ return value;
+}
+
+QString QAccessibleItemRow::text(Text t, int child) const
+{
+ QString value;
+ if (t == Name) {
+ value = text_helper(child);
+ } else if (t == Value) {
+#ifndef QT_NO_TREEVIEW
+ if (qobject_cast<const QTreeView*>(view)) {
+ if (child == 0)
+ value = QString::number(treeLevel());
+ } else
+#endif
+ {
+ value = text_helper(child);
+ }
+ } else if (t == Description) {
+#ifndef QT_NO_TREEVIEW
+ if (child == 0 && qobject_cast<const QTreeView*>(view)) {
+ // We store the tree coordinates of the current item in the description.
+ // This enables some screen readers to report where the focus is
+ // in a tree view. (works in JAWS). Also, Firefox does the same thing.
+ // For instance the description "L2, 4 of 25 with 24" means
+ // "L2": Tree Level 2
+ // "4 of 25": We are item 4 out of in total 25 other siblings
+ // "with 24": We have 24 children. (JAWS does not read this number)
+
+ // level
+ int level = treeLevel();
+
+ QAbstractItemModel *m = view->model();
+ // totalSiblings and itemIndex
+ QModelIndex parent = row.parent();
+ int rowCount = m->rowCount(parent);
+ int itemIndex = -1;
+ int totalSiblings = 0;
+ for (int i = 0 ; i < rowCount; ++i) {
+ QModelIndex sibling = row.sibling(i, 0);
+ if (!view->isIndexHidden(sibling))
+ ++totalSiblings;
+ if (row == sibling)
+ itemIndex = totalSiblings;
+ }
+ int totalChildren = m->rowCount(row); // JAWS does not report child count, so we do
+ // this simple and efficient.
+ // (don't check if they are all visible).
+ value = QString::fromAscii("L%1, %2 of %3 with %4").arg(level).arg(itemIndex).arg(totalSiblings).arg(totalChildren);
+ } else
+#endif // QT_NO_TREEVIEW
+ {
+ if (!m_header) {
+ if (child == 0 && children().count() >= 1)
+ child = 1;
+ if (verticalHeader()) {
+ if (child == 1) {
+ value = view->model()->headerData(row.row(), Qt::Vertical).toString();
+ }
+ --child;
+ }
+ if (child) {
+ QModelIndex idx = childIndex(child);
+ value = idx.model()->data(idx, Qt::AccessibleDescriptionRole).toString();
+ }
+
+ }
+ }
+ }
+ return value;
+}
+
+void QAccessibleItemRow::setText(Text t, int child, const QString &text)
+{
+ if (m_header) {
+ if (child)
+ view->model()->setHeaderData(child - 1, Qt::Horizontal, text);
+ // child == 0 means the cell to the left of the horizontal header, which is empty!?
+ } else {
+ if (!child) {
+ if (children().count() == 1)
+ child = 1;
+ else
+ return;
+ }
+
+ if (verticalHeader()) {
+ if (child == 1) {
+ view->model()->setHeaderData(row.row(), Qt::Vertical, text);
+ return;
+ }
+ --child;
+ }
+ QModelIndex idx = childIndex(child);
+ if (!idx.isValid())
+ return;
+
+ switch (t) {
+ case Description:
+ const_cast<QAbstractItemModel *>(idx.model())->setData(idx, text,
+ Qt::AccessibleDescriptionRole);
+ break;
+ case Value:
+ const_cast<QAbstractItemModel *>(idx.model())->setData(idx, text, Qt::EditRole);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+QModelIndex QAccessibleItemRow::childIndex(int child) const
+{
+ QList<QModelIndex> kids = children();
+ Q_ASSERT(child >= 1 && child <= kids.count());
+ return kids.at(child - 1);
+}
+
+QList<QModelIndex> QAccessibleItemRow::children() const
+{
+ QList<QModelIndex> kids;
+ for (int i = 0; i < row.model()->columnCount(row.parent()); ++i) {
+ QModelIndex idx = row.model()->index(row.row(), i, row.parent());
+ if (!view->isIndexHidden(idx)) {
+ kids << idx;
+ }
+ }
+ return kids;
+}
+
+bool QAccessibleItemRow::isValid() const
+{
+ return m_header ? true : row.isValid();
+}
+
+QObject *QAccessibleItemRow::object() const
+{
+ return 0;
+}
+
+int QAccessibleItemRow::childCount() const
+{
+ int count = 0;
+ if (QHeaderView *header = horizontalHeader()) {
+ count = header->count() - header->hiddenSectionCount();
+ } else {
+ count = children().count();
+ }
+#ifndef QT_NO_TABLEVIEW
+ if (qobject_cast<const QTableView*>(view)) {
+ if (verticalHeader())
+ ++count;
+ }
+#endif
+ return count;
+}
+
+int QAccessibleItemRow::indexOfChild(const QAccessibleInterface *iface) const
+{
+ if (!iface || iface->role(0) != Row)
+ return -1;
+
+ //### meaningless code?
+ QList<QModelIndex> kids = children();
+ QModelIndex idx = static_cast<const QAccessibleItemRow *>(iface)->row;
+ if (!idx.isValid())
+ return -1;
+ return kids.indexOf(idx) + 1;
+}
+
+QAccessible::Relation QAccessibleItemRow::relationTo(int child, const QAccessibleInterface *other,
+ int otherChild) const
+{
+ if (!child && !otherChild && other->object() == view)
+ return Child;
+ if (!child && !otherChild && other == this)
+ return Self;
+ if (!child && otherChild && other == this)
+ return Ancestor;
+ if (child && otherChild && other == this)
+ return Sibling;
+ return Unrelated;
+}
+
+int QAccessibleItemRow::childAt(int x, int y) const
+{
+ if (!view || !view->isVisible())
+ return -1;
+
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(x, y))
+ return i;
+ }
+ return -1;
+}
+
+QAbstractItemView::CursorAction QAccessibleItemRow::toCursorAction(
+ QAccessible::Relation rel)
+{
+ switch (rel) {
+ case QAccessible::Up:
+ return QAbstractItemView::MoveUp;
+ case QAccessible::Down:
+ return QAbstractItemView::MoveDown;
+ case QAccessible::Left:
+ return QAbstractItemView::MoveLeft;
+ case QAccessible::Right:
+ return QAbstractItemView::MoveRight;
+ default:
+ Q_ASSERT(false);
+ }
+ // should never be reached.
+ return QAbstractItemView::MoveRight;
+}
+
+int QAccessibleItemRow::navigate(RelationFlag relation, int index,
+ QAccessibleInterface **iface) const
+{
+ *iface = 0;
+ if (!view)
+ return -1;
+
+ switch (relation) {
+ case Ancestor: {
+ if (!index)
+ return -1;
+ QAccessibleItemView *ancestor = new QAccessibleItemView(view->viewport());
+ if (index == 1) {
+ *iface = ancestor;
+ return 0;
+ } else if (index > 1) {
+ int ret = ancestor->navigate(Ancestor, index - 1, iface);
+ delete ancestor;
+ return ret;
+ }
+ }
+ case Child: {
+ if (!index)
+ return -1;
+ if (index < 1 && index > childCount())
+ return -1;
+
+ return index;}
+ case Sibling:
+ if (index) {
+ QAccessibleInterface *ifaceParent = 0;
+ navigate(Ancestor, 1, &ifaceParent);
+ if (ifaceParent) {
+ int entry = ifaceParent->navigate(Child, index, iface);
+ delete ifaceParent;
+ return entry;
+ }
+ }
+ return -1;
+ case Up:
+ case Down:
+ case Left:
+ case Right: {
+ // This is in the "not so nice" category. In order to find out which item
+ // is geometrically around, we have to set the current index, navigate
+ // and restore the index as well as the old selection
+ view->setUpdatesEnabled(false);
+ const QModelIndex oldIdx = view->currentIndex();
+ QList<QModelIndex> kids = children();
+ const QModelIndex currentIndex = index ? kids.at(index - 1) : QModelIndex(row);
+ const QItemSelection oldSelection = view->selectionModel()->selection();
+ view->setCurrentIndex(currentIndex);
+ const QModelIndex idx = view->moveCursor(toCursorAction(relation), Qt::NoModifier);
+ view->setCurrentIndex(oldIdx);
+ view->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
+ view->setUpdatesEnabled(true);
+ if (!idx.isValid())
+ return -1;
+
+ if (idx.parent() != row.parent() || idx.row() != row.row())
+ *iface = new QAccessibleItemRow(view, idx);
+ return index ? kids.indexOf(idx) + 1 : 0; }
+ default:
+ break;
+ }
+
+ return -1;
+}
+
+QAccessible::Role QAccessibleItemRow::role(int child) const
+{
+ if (false) {
+#ifndef QT_NO_TREEVIEW
+ } else if (qobject_cast<const QTreeView*>(view)) {
+ if (horizontalHeader()) {
+ if (!child)
+ return Row;
+ return ColumnHeader;
+ }
+ return TreeItem;
+#endif
+#ifndef QT_NO_LISTVIEW
+ } else if (qobject_cast<const QListView*>(view)) {
+ return ListItem;
+#endif
+#ifndef QT_NO_TABLEVIEW
+ } else if (qobject_cast<const QTableView *>(view)) {
+ if (!child)
+ return Row;
+ if (child == 1) {
+ if (verticalHeader())
+ return RowHeader;
+ }
+ if (m_header)
+ return ColumnHeader;
+#endif
+ }
+ return Cell;
+}
+
+QAccessible::State QAccessibleItemRow::state(int child) const
+{
+ State st = Normal;
+
+ if (!view)
+ return st;
+
+ QAccessibleInterface *parent = 0;
+ QRect globalRect;
+ if (navigate(Ancestor, 1, &parent) == 0) {
+ globalRect = parent->rect(0);
+ delete parent;
+ }
+ if (!globalRect.intersects(rect(child)))
+ st |= Invisible;
+
+ if (!horizontalHeader()) {
+ if (!(st & Invisible)) {
+ if (child) {
+ if (QHeaderView *vheader = verticalHeader() ) {
+ if (child == 1) {
+ if (!vheader->isVisible())
+ st |= Invisible;
+ }
+ --child;
+ }
+ if (child) {
+ QModelIndex idx = childIndex(child);
+ if (!idx.isValid())
+ return st;
+
+ if (view->selectionModel()->isSelected(idx))
+ st |= Selected;
+ if (view->selectionModel()->currentIndex() == idx)
+ st |= Focused;
+ if (idx.model()->data(idx, Qt::CheckStateRole).toInt() == Qt::Checked)
+ st |= Checked;
+
+ Qt::ItemFlags flags = idx.flags();
+ if (flags & Qt::ItemIsSelectable) {
+ st |= Selectable;
+ if (view->selectionMode() == QAbstractItemView::MultiSelection)
+ st |= MultiSelectable;
+ if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
+ st |= ExtSelectable;
+ }
+ }
+ } else {
+ Qt::ItemFlags flags = row.flags();
+ if (flags & Qt::ItemIsSelectable) {
+ st |= Selectable;
+ st |= Focusable;
+ }
+ if (view->selectionModel()->isRowSelected(row.row(), row.parent()))
+ st |= Selected;
+ if (view->selectionModel()->currentIndex().row() == row.row())
+ st |= Focused;
+ }
+ }
+ }
+
+ return st;
+}
+
+int QAccessibleItemRow::userActionCount(int) const
+{
+ return 0;
+}
+
+QString QAccessibleItemRow::actionText(int, Text, int) const
+{
+ return QString();
+}
+
+static QItemSelection rowAt(const QModelIndex &idx)
+{
+ return QItemSelection(idx.sibling(idx.row(), 0),
+ idx.sibling(idx.row(), idx.model()->columnCount(idx.parent())));
+}
+
+bool QAccessibleItemRow::doAction(int action, int child, const QVariantList & /*params*/)
+{
+ if (!view)
+ return false;
+
+ if (verticalHeader())
+ --child;
+
+ QModelIndex idx = child ? childIndex(child) : QModelIndex(row);
+ if (!idx.isValid())
+ return false;
+
+ QItemSelectionModel::SelectionFlags command = QItemSelectionModel::NoUpdate;
+
+ switch (action) {
+ case SetFocus:
+ view->setCurrentIndex(idx);
+ return true;
+ case ExtendSelection:
+ if (!child)
+ return false;
+ view->selectionModel()->select(QItemSelection(view->currentIndex(), idx),
+ QItemSelectionModel::SelectCurrent);
+ return true;
+ case Select:
+ command = QItemSelectionModel::ClearAndSelect;
+ break;
+ case ClearSelection:
+ command = QItemSelectionModel::Clear;
+ break;
+ case RemoveSelection:
+ command = QItemSelectionModel::Deselect;
+ break;
+ case AddToSelection:
+ command = QItemSelectionModel::SelectCurrent;
+ break;
+ }
+ if (command == QItemSelectionModel::NoUpdate)
+ return false;
+
+ if (child)
+ view->selectionModel()->select(idx, command);
+ else
+ view->selectionModel()->select(rowAt(row), command);
+ return true;
+}
+
+class ModelIndexIterator
+{
+public:
+ ModelIndexIterator(QAbstractItemView *view, const QModelIndex &start = QModelIndex()) : m_view(view)
+ {
+#ifndef QT_NO_LISTVIEW
+ list = qobject_cast<QListView*>(m_view);
+#endif
+#ifndef QT_NO_TREEVIEW
+ tree = qobject_cast<QTreeView*>(m_view);
+#endif
+#ifndef QT_NO_TABLEVIEW
+ table = qobject_cast<QTableView*>(m_view);
+#endif
+ if (start.isValid()) {
+ m_current = start;
+ } else if (m_view && m_view->model()) {
+ m_current = view->rootIndex().isValid() ?
+ view->rootIndex().child(0,0) : view->model()->index(0, 0);
+ }
+ }
+
+ bool next(int count = 1) {
+ for (int i = 0; i < count; ++i) {
+ do {
+ if (m_current.isValid()) {
+ const QAbstractItemModel *m = m_current.model();
+#ifndef QT_NO_TREEVIEW
+ if (tree && m_current.model()->hasChildren(m_current) && tree->isExpanded(m_current)) {
+ m_current = m_current.child(0, 0);
+ } else
+#endif
+ {
+ int row = m_current.row();
+ QModelIndex par = m_current.parent();
+
+ // Go up to the parent if we reach the end of the rows
+ // If m_curent becomses invalid, stop going up.
+ while (row + 1 >= m->rowCount(par)) {
+ m_current = par;
+ if (m_current.isValid()) {
+ row = m_current.row();
+ par = m_current.parent();
+ } else {
+ row = 0;
+ par = QModelIndex();
+ break;
+ }
+ }
+
+ if (m_current.isValid())
+ m_current = m_current.sibling(row + 1, 0);
+ }
+ }
+ } while (isHidden());
+ }
+ return m_current.isValid();
+ }
+
+ bool isHidden() const {
+ if (false) {
+#ifndef QT_NO_LISTVIEW
+ } else if (list) {
+ return list->isRowHidden(m_current.row());
+#endif
+#ifndef QT_NO_TREEVIEW
+ } else if (tree) {
+ return tree->isRowHidden(m_current.row(), m_current.parent());
+#endif
+#ifndef QT_NO_TABLEVIEW
+ } else if (table) {
+ return table->isRowHidden(m_current.row());
+#endif
+ }
+ return false;
+ }
+
+ QModelIndex current() const {
+ return m_current;
+ }
+
+private:
+ QModelIndex m_current;
+ QAbstractItemView *m_view;
+
+#ifndef QT_NO_TREEVIEW
+ QTreeView *tree;
+#endif
+#ifndef QT_NO_LISTVIEW
+ QListView *list;
+#endif
+#ifndef QT_NO_TABLEVIEW
+ QTableView *table;
+#endif
+};
+
+QAccessibleItemView::QAccessibleItemView(QWidget *w)
+ : QAccessibleAbstractScrollArea(w->objectName() == QLatin1String("qt_scrollarea_viewport") ? w->parentWidget() : w)
+{
+ atVP = w->objectName() == QLatin1String("qt_scrollarea_viewport");
+
+}
+
+
+QHeaderView *QAccessibleItemView::horizontalHeader() const
+{
+ QHeaderView *header = 0;
+ if (false) {
+#ifndef QT_NO_TABLEVIEW
+ } else if (const QTableView *tv = qobject_cast<const QTableView*>(itemView())) {
+ header = tv->horizontalHeader();
+#endif
+#ifndef QT_NO_TREEVIEW
+ } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(itemView())) {
+ header = tv->header();
+#endif
+ }
+ return header;
+}
+
+QHeaderView *QAccessibleItemView::verticalHeader() const
+{
+ QHeaderView *header = 0;
+ if (false) {
+#ifndef QT_NO_TABLEVIEW
+ } else if (const QTableView *tv = qobject_cast<const QTableView*>(itemView())) {
+ header = tv->verticalHeader();
+#endif
+ }
+ return header;
+}
+
+
+bool QAccessibleItemView::isValidChildRole(QAccessible::Role role) const
+{
+ if (atViewport()) {
+ if (false) {
+#ifndef QT_NO_TREEVIEW
+ } else if (qobject_cast<const QTreeView*>(itemView())) {
+ return (role == TreeItem || role == Row);
+#endif
+#ifndef QT_NO_LISTVIEW
+ } else if (qobject_cast<const QListView*>(itemView())) {
+ return (role == ListItem);
+#endif
+ }
+ // TableView
+ return role == Row;
+ } else {
+ if (false) {
+#ifndef QT_NO_TREEVIEW
+ } else if (qobject_cast<const QTreeView*>(itemView())) {
+ return (role == Tree);
+#endif
+#ifndef QT_NO_LISTVIEW
+ } else if (qobject_cast<const QListView*>(itemView())) {
+ return (role == List);
+#endif
+ }
+ // TableView
+ return (role == Table);
+ }
+}
+
+QObject *QAccessibleItemView::object() const
+{
+ QObject *view = QAccessibleAbstractScrollArea::object();
+ Q_ASSERT(qobject_cast<const QAbstractItemView *>(view));
+ if (atViewport())
+ view = qobject_cast<const QAbstractItemView *>(view)->viewport();
+ return view;
+}
+
+QAbstractItemView *QAccessibleItemView::itemView() const
+{
+ return qobject_cast<QAbstractItemView *>(QAccessibleAbstractScrollArea::object());
+}
+
+int QAccessibleItemView::indexOfChild(const QAccessibleInterface *iface) const
+{
+ if (atViewport()) {
+ if (!iface || !isValidChildRole(iface->role(0)))
+ return -1;
+
+ int entry = -1;
+ // ### This will fail if a row is hidden.
+ const QAccessibleItemRow *ifRow = static_cast<const QAccessibleItemRow *>(iface);
+ if (ifRow->horizontalHeader())
+ return 1;
+
+ QModelIndex idx = ifRow->row;
+ if (!idx.isValid())
+ return -1;
+
+ entry = entryFromIndex(idx);
+ if (horizontalHeader())
+ ++entry;
+
+ return entry;
+
+ } else {
+ return QAccessibleAbstractScrollArea::indexOfChild(iface);
+ }
+}
+
+QModelIndex QAccessibleItemView::childIndex(int child) const
+{
+ if (!atViewport())
+ return QModelIndex();
+ ModelIndexIterator it(itemView());
+ it.next(child - 1);
+ return it.current();
+}
+
+int QAccessibleItemView::entryFromIndex(const QModelIndex &index) const
+{
+ int entry = -1;
+ if (false) {
+#ifndef QT_NO_TREEVIEW
+ } else if (QTreeView *tree = qobject_cast<QTreeView*>(itemView())) {
+ entry = tree->visualIndex(index) + 1;
+#endif
+#ifndef QT_NO_LISTVIEW
+ } else if (QListView *list = qobject_cast<QListView*>(itemView())) {
+ entry = list->visualIndex(index) + 1;
+#endif
+#ifndef QT_NO_TABLEVIEW
+ } else if (QTableView *table = qobject_cast<QTableView*>(itemView())) {
+ entry = table->visualIndex(index) + 1;
+#endif
+ }
+ return entry;
+}
+
+int QAccessibleItemView::childCount() const
+{
+ if (atViewport()) {
+ if (itemView()->model() == 0)
+ return 0;
+ QAbstractItemModel *m = itemView()->model();
+ QModelIndex idx = m->index(0,0);
+ if (!idx.isValid())
+ return 0;
+ ModelIndexIterator it(itemView());
+ int count = 1;
+ while (it.next()) {
+ ++count;
+ }
+ if (horizontalHeader())
+ ++count;
+
+ return count;
+ } else {
+ return QAccessibleAbstractScrollArea::childCount();
+ }
+}
+
+QString QAccessibleItemView::text(Text t, int child) const
+{
+ if (atViewport()) {
+ if (!child)
+ return QAccessibleAbstractScrollArea::text(t, child);
+
+ QAccessibleItemRow item(itemView(), childIndex(child));
+ return item.text(t, 1);
+ } else {
+ return QAccessibleAbstractScrollArea::text(t, child);
+ }
+}
+
+void QAccessibleItemView::setText(Text t, int child, const QString &text)
+{
+ if (atViewport()) {
+ if (!child) {
+ QAccessibleAbstractScrollArea::setText(t, child, text);
+ return;
+ }
+
+ QAccessibleItemRow item(itemView(), childIndex(child));
+ item.setText(t, 1, text);
+ } else {
+ QAccessibleAbstractScrollArea::setText(t, child, text);
+ }
+}
+
+QRect QAccessibleItemView::rect(int child) const
+{
+ if (atViewport()) {
+ QRect r;
+ if (!child) {
+ // Make sure that the rect *include* the vertical and horizontal headers, while
+ // not including the potential vertical and horizontal scrollbars.
+ QAbstractItemView *w = itemView();
+
+ int vscrollWidth = 0;
+ const QScrollBar *sb = w->verticalScrollBar();
+ if (sb && sb->isVisible())
+ vscrollWidth = sb->width();
+
+ int hscrollHeight = 0;
+ sb = w->horizontalScrollBar();
+ if (sb && sb->isVisible())
+ hscrollHeight = sb->height();
+
+ QPoint globalPos = w->mapToGlobal(QPoint(0,0));
+ r = w->rect().translated(globalPos);
+ if (w->isRightToLeft()) {
+ r.adjust(vscrollWidth, 0, 0, -hscrollHeight);
+ } else {
+ r.adjust(0, 0, -vscrollWidth, -hscrollHeight);
+ }
+ } else {
+ QAccessibleInterface *iface = 0;
+ if (navigate(Child, child, &iface) == 0) {
+ r = iface->rect(0);
+ delete iface;
+ }
+ }
+ return r;
+ } else {
+ QRect r = QAccessibleAbstractScrollArea::rect(child);
+ if (child == 1) {
+ // include the potential vertical and horizontal headers
+
+ const QHeaderView *header = verticalHeader();
+ int headerWidth = (header && header->isVisible()) ? header->width() : 0;
+ header = horizontalHeader();
+ int headerHeight= (header && header->isVisible()) ? header->height() : 0;
+ if (itemView()->isRightToLeft()) {
+ r.adjust(0, -headerHeight, headerWidth, 0);
+ } else {
+ r.adjust(-headerWidth, -headerHeight, 0, 0);
+ }
+ }
+ return r;
+ }
+}
+
+int QAccessibleItemView::childAt(int x, int y) const
+{
+ if (atViewport()) {
+ QPoint p(x, y);
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(p))
+ return i;
+ }
+ return -1;
+ } else {
+ return QAccessibleAbstractScrollArea::childAt(x, y);
+ }
+}
+
+QAccessible::Role QAccessibleItemView::role(int child) const
+{
+ if ((!atViewport() && child) || (atViewport() && child == 0)) {
+ QAbstractItemView *view = itemView();
+#ifndef QT_NO_TABLEVIEW
+ if (qobject_cast<QTableView *>(view))
+ return Table;
+#endif
+#ifndef QT_NO_LISTVIEW
+ if (qobject_cast<QListView *>(view))
+ return List;
+#endif
+ return Tree;
+ }
+ if (atViewport()) {
+ if (child)
+ return Row;
+ }
+
+ return QAccessibleAbstractScrollArea::role(child);
+}
+
+QAccessible::State QAccessibleItemView::state(int child) const
+{
+ State st = Normal;
+
+ if (itemView() == 0)
+ return State(Unavailable);
+
+ bool queryViewPort = (atViewport() && child == 0) || (!atViewport() && child == 1);
+ if (queryViewPort) {
+ if (itemView()->selectionMode() != QAbstractItemView::NoSelection) {
+ st |= Selectable;
+ st |= Focusable;
+ }
+ } else if (atViewport()) { // children of viewport
+ if (horizontalHeader())
+ --child;
+ if (child) {
+ QAccessibleItemRow item(itemView(), childIndex(child));
+ st |= item.state(0);
+ }
+ } else if (!atViewport() && child != 1) {
+ st = QAccessibleAbstractScrollArea::state(child);
+ }
+ return st;
+}
+
+bool QAccessibleItemView::isValid() const
+{
+ if (atViewport())
+ return QAccessibleWidgetEx::isValid();
+ else
+ return QAccessibleAbstractScrollArea::isValid();
+}
+
+int QAccessibleItemView::navigate(RelationFlag relation, int index,
+ QAccessibleInterface **iface) const
+{
+ if (atViewport()) {
+ if (relation == Ancestor && index == 1) {
+ *iface = new QAccessibleItemView(itemView());
+ return 0;
+ } else if (relation == Child && index >= 1) {
+ if (horizontalHeader()) {
+ if (index == 1) {
+ *iface = new QAccessibleItemRow(itemView(), QModelIndex(), true);
+ return 0;
+ }
+ --index;
+ }
+
+ //###JAS hidden rows..
+ QModelIndex idx = childIndex(index);
+ if (idx.isValid()) {
+ *iface = new QAccessibleItemRow(itemView(), idx);
+ return 0;
+ }
+ } else if (relation == Sibling && index >= 1) {
+ QAccessibleInterface *parent = new QAccessibleItemView(itemView());
+ return parent->navigate(Child, index, iface);
+ }
+ *iface = 0;
+ return -1;
+ } else {
+ return QAccessibleAbstractScrollArea::navigate(relation, index, iface);
+ }
+}
+
+/* returns the model index for a given row and column */
+QModelIndex QAccessibleItemView::index(int row, int column) const
+{
+ return itemView()->model()->index(row, column);
+}
+
+QAccessibleInterface *QAccessibleItemView::accessibleAt(int row, int column)
+{
+ QWidget *indexWidget = itemView()->indexWidget(index(row, column));
+ return QAccessible::queryAccessibleInterface(indexWidget);
+}
+
+/* We don't have a concept of a "caption" in Qt's standard widgets */
+QAccessibleInterface *QAccessibleItemView::caption()
+{
+ return 0;
+}
+
+/* childIndex is row * columnCount + columnIndex */
+int QAccessibleItemView::childIndex(int rowIndex, int columnIndex)
+{
+ return rowIndex * itemView()->model()->columnCount() + columnIndex;
+}
+
+/* Return the header data as column description */
+QString QAccessibleItemView::columnDescription(int column)
+{
+ return itemView()->model()->headerData(column, Qt::Horizontal).toString();
+}
+
+/* We don't support column spanning atm */
+int QAccessibleItemView::columnSpan(int /* row */, int /* column */)
+{
+ return 1;
+}
+
+/* Return the horizontal header view */
+QAccessibleInterface *QAccessibleItemView::columnHeader()
+{
+#ifndef QT_NO_TREEVIEW
+ if (QTreeView *tree = qobject_cast<QTreeView *>(itemView()))
+ return QAccessible::queryAccessibleInterface(tree->header());
+#endif
+#ifndef QT_NO_TABLEVIEW
+ if (QTableView *table = qobject_cast<QTableView *>(itemView()))
+ return QAccessible::queryAccessibleInterface(table->horizontalHeader());
+#endif
+ return 0;
+}
+
+int QAccessibleItemView::columnIndex(int childIndex)
+{
+ int columnCount = itemView()->model()->columnCount();
+ if (!columnCount)
+ return 0;
+
+ return childIndex % columnCount;
+}
+
+int QAccessibleItemView::columnCount()
+{
+ return itemView()->model()->columnCount();
+}
+
+int QAccessibleItemView::rowCount()
+{
+ return itemView()->model()->rowCount();
+}
+
+int QAccessibleItemView::selectedColumnCount()
+{
+ return itemView()->selectionModel()->selectedColumns().count();
+}
+
+int QAccessibleItemView::selectedRowCount()
+{
+ return itemView()->selectionModel()->selectedRows().count();
+}
+
+QString QAccessibleItemView::rowDescription(int row)
+{
+ return itemView()->model()->headerData(row, Qt::Vertical).toString();
+}
+
+/* We don't support row spanning */
+int QAccessibleItemView::rowSpan(int /*row*/, int /*column*/)
+{
+ return 1;
+}
+
+QAccessibleInterface *QAccessibleItemView::rowHeader()
+{
+#ifndef QT_NO_TABLEVIEW
+ if (QTableView *table = qobject_cast<QTableView *>(itemView()))
+ return QAccessible::queryAccessibleInterface(table->verticalHeader());
+#endif
+ return 0;
+}
+
+int QAccessibleItemView::rowIndex(int childIndex)
+{
+ int columnCount = itemView()->model()->columnCount();
+ if (!columnCount)
+ return 0;
+
+ return int(childIndex / columnCount);
+}
+
+int QAccessibleItemView::selectedRows(int maxRows, QList<int> *rows)
+{
+ Q_ASSERT(rows);
+
+ const QModelIndexList selRows = itemView()->selectionModel()->selectedRows();
+ int maxCount = qMin(selRows.count(), maxRows);
+
+ for (int i = 0; i < maxCount; ++i)
+ rows->append(selRows.at(i).row());
+
+ return maxCount;
+}
+
+int QAccessibleItemView::selectedColumns(int maxColumns, QList<int> *columns)
+{
+ Q_ASSERT(columns);
+
+ const QModelIndexList selColumns = itemView()->selectionModel()->selectedColumns();
+ int maxCount = qMin(selColumns.count(), maxColumns);
+
+ for (int i = 0; i < maxCount; ++i)
+ columns->append(selColumns.at(i).row());
+
+ return maxCount;
+}
+
+/* Qt widgets don't have a concept of a summary */
+QAccessibleInterface *QAccessibleItemView::summary()
+{
+ return 0;
+}
+
+bool QAccessibleItemView::isColumnSelected(int column)
+{
+ return itemView()->selectionModel()->isColumnSelected(column, QModelIndex());
+}
+
+bool QAccessibleItemView::isRowSelected(int row)
+{
+ return itemView()->selectionModel()->isRowSelected(row, QModelIndex());
+}
+
+bool QAccessibleItemView::isSelected(int row, int column)
+{
+ return itemView()->selectionModel()->isSelected(index(row, column));
+}
+
+void QAccessibleItemView::selectRow(int row)
+{
+ QItemSelectionModel *s = itemView()->selectionModel();
+ s->select(index(row, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
+}
+
+void QAccessibleItemView::selectColumn(int column)
+{
+ QItemSelectionModel *s = itemView()->selectionModel();
+ s->select(index(0, column), QItemSelectionModel::Select | QItemSelectionModel::Columns);
+}
+
+void QAccessibleItemView::unselectRow(int row)
+{
+ QItemSelectionModel *s = itemView()->selectionModel();
+ s->select(index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
+}
+
+void QAccessibleItemView::unselectColumn(int column)
+{
+ QItemSelectionModel *s = itemView()->selectionModel();
+ s->select(index(0, column), QItemSelectionModel::Deselect | QItemSelectionModel::Columns);
+}
+
+void QAccessibleItemView::cellAtIndex(int index, int *row, int *column, int *rSpan,
+ int *cSpan, bool *isSelect)
+{
+ *row = rowIndex(index);
+ *column = columnIndex(index);
+ *rSpan = rowSpan(*row, *column);
+ *cSpan = columnSpan(*row, *column);
+ *isSelect = isSelected(*row, *column);
+}
+
+/*!
+ \class QAccessibleHeader
+ \brief The QAccessibleHeader class implements the QAccessibleInterface for header widgets.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ Constructs a QAccessibleHeader object for \a w.
+*/
+QAccessibleHeader::QAccessibleHeader(QWidget *w)
+: QAccessibleWidgetEx(w)
+{
+ Q_ASSERT(header());
+ addControllingSignal(QLatin1String("sectionClicked(int)"));
+}
+
+/*! Returns the QHeaderView. */
+QHeaderView *QAccessibleHeader::header() const
+{
+ return qobject_cast<QHeaderView*>(object());
+}
+
+/*! \reimp */
+QRect QAccessibleHeader::rect(int child) const
+{
+ if (!child)
+ return QAccessibleWidgetEx::rect(0);
+
+ QHeaderView *h = header();
+ QPoint zero = h->mapToGlobal(QPoint(0, 0));
+ int sectionSize = h->sectionSize(child - 1);
+ int sectionPos = h->sectionPosition(child - 1);
+ return h->orientation() == Qt::Horizontal
+ ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, h->height())
+ : QRect(zero.x(), zero.y() + sectionPos, h->width(), sectionSize);
+}
+
+/*! \reimp */
+int QAccessibleHeader::childCount() const
+{
+ return header()->count();
+}
+
+/*! \reimp */
+QString QAccessibleHeader::text(Text t, int child) const
+{
+ QString str;
+
+ if (child > 0 && child <= childCount()) {
+ switch (t) {
+ case Name:
+ str = header()->model()->headerData(child - 1, header()->orientation()).toString();
+ break;
+ case Description: {
+ QAccessibleEvent event(QEvent::AccessibilityDescription, child);
+ if (QApplication::sendEvent(widget(), &event))
+ str = event.value();
+ break; }
+ case Help: {
+ QAccessibleEvent event(QEvent::AccessibilityHelp, child);
+ if (QApplication::sendEvent(widget(), &event))
+ str = event.value();
+ break; }
+ default:
+ break;
+ }
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, child);
+ return str;
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleHeader::role(int) const
+{
+ return (header()->orientation() == Qt::Horizontal) ? ColumnHeader : RowHeader;
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleHeader::state(int child) const
+{
+ State state = QAccessibleWidgetEx::state(child);
+
+ if (child) {
+ int section = child - 1;
+ if (header()->isSectionHidden(section))
+ state |= Invisible;
+ if (header()->resizeMode(section) != QHeaderView::Custom)
+ state |= Sizeable;
+ } else {
+ if (header()->isMovable())
+ state |= Movable;
+ }
+ if (!header()->isClickable())
+ state |= Unavailable;
+ return state;
+}
+#endif // QT_NO_ITEMVIEWS
+
+#ifndef QT_NO_TABBAR
+/*!
+ \class QAccessibleTabBar
+ \brief The QAccessibleTabBar class implements the QAccessibleInterface for tab bars.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ Constructs a QAccessibleTabBar object for \a w.
+*/
+QAccessibleTabBar::QAccessibleTabBar(QWidget *w)
+: QAccessibleWidgetEx(w)
+{
+ Q_ASSERT(tabBar());
+}
+
+/*! Returns the QTabBar. */
+QTabBar *QAccessibleTabBar::tabBar() const
+{
+ return qobject_cast<QTabBar*>(object());
+}
+
+QAbstractButton *QAccessibleTabBar::button(int child) const
+{
+ if (child <= tabBar()->count())
+ return 0;
+ QTabBarPrivate * const tabBarPrivate = tabBar()->d_func();
+ if (child - tabBar()->count() == 1)
+ return tabBarPrivate->leftB;
+ if (child - tabBar()->count() == 2)
+ return tabBarPrivate->rightB;
+ Q_ASSERT(false);
+ return 0;
+}
+
+/*! \reimp */
+QRect QAccessibleTabBar::rect(int child) const
+{
+ if (!child || !tabBar()->isVisible())
+ return QAccessibleWidgetEx::rect(0);
+
+ QPoint tp = tabBar()->mapToGlobal(QPoint(0,0));
+ QRect rec;
+ if (child <= tabBar()->count()) {
+ rec = tabBar()->tabRect(child - 1);
+ } else {
+ QWidget *widget = button(child);
+ rec = widget ? widget->geometry() : QRect();
+ }
+ return QRect(tp.x() + rec.x(), tp.y() + rec.y(), rec.width(), rec.height());
+}
+
+/*! \reimp */
+int QAccessibleTabBar::childCount() const
+{
+ // tabs + scroll buttons
+ return tabBar()->count() + 2;
+}
+
+/*! \reimp */
+QString QAccessibleTabBar::text(Text t, int child) const
+{
+ QString str;
+
+ if (child > tabBar()->count()) {
+ bool left = child - tabBar()->count() == 1;
+ switch (t) {
+ case Name:
+ return left ? QTabBar::tr("Scroll Left") : QTabBar::tr("Scroll Right");
+ default:
+ break;
+ }
+ } else {
+ switch (t) {
+ case Name:
+ if (child > 0)
+ return qt_accStripAmp(tabBar()->tabText(child - 1));
+ else if (tabBar()->currentIndex() != -1)
+ return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex()));
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, child);;
+ return str;
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleTabBar::role(int child) const
+{
+ if (!child)
+ return PageTabList;
+ if (child > tabBar()->count())
+ return PushButton;
+ return PageTab;
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleTabBar::state(int child) const
+{
+ State st = QAccessibleWidgetEx::state(0);
+
+ if (!child)
+ return st;
+
+ QTabBar *tb = tabBar();
+
+ if (child > tb->count()) {
+ QWidget *bt = button(child);
+ if (!bt)
+ return st;
+ if (bt->isEnabled() == false)
+ st |= Unavailable;
+ if (bt->isVisible() == false)
+ st |= Invisible;
+ if (bt->focusPolicy() != Qt::NoFocus && bt->isActiveWindow())
+ st |= Focusable;
+ if (bt->hasFocus())
+ st |= Focused;
+ return st;
+ }
+
+ if (!tb->isTabEnabled(child - 1))
+ st |= Unavailable;
+ else
+ st |= Selectable;
+
+ if (!tb->currentIndex() == child - 1)
+ st |= Selected;
+
+ return st;
+}
+
+/*! \reimp */
+bool QAccessibleTabBar::doAction(int action, int child, const QVariantList &)
+{
+ if (!child)
+ return false;
+
+ if (action != QAccessible::DefaultAction && action != QAccessible::Press)
+ return false;
+
+ if (child > tabBar()->count()) {
+ QAbstractButton *bt = button(child);
+ if (!bt->isEnabled())
+ return false;
+ bt->animateClick();
+ return true;
+ }
+ if (!tabBar()->isTabEnabled(child - 1))
+ return false;
+ tabBar()->setCurrentIndex(child - 1);
+ return true;
+}
+
+/*!
+ Selects the item with index \a child if \a on is true; otherwise
+ unselects it. If \a extend is true and the selection mode is not
+ \c Single and there is an existing selection, the selection is
+ extended to include all the items from the existing selection up
+ to and including the item with index \a child. Returns true if a
+ selection was made or extended; otherwise returns false.
+
+ \sa selection() clearSelection()
+*/
+bool QAccessibleTabBar::setSelected(int child, bool on, bool extend)
+{
+ if (!child || !on || extend || child > tabBar()->count())
+ return false;
+
+ if (!tabBar()->isTabEnabled(child - 1))
+ return false;
+ tabBar()->setCurrentIndex(child - 1);
+ return true;
+}
+
+/*!
+ Returns a (possibly empty) list of indexes of the items selected
+ in the list box.
+
+ \sa setSelected() clearSelection()
+*/
+QVector<int> QAccessibleTabBar::selection() const
+{
+ QVector<int> array;
+ if (tabBar()->currentIndex() != -1)
+ array +=tabBar()->currentIndex() + 1;
+ return array;
+}
+
+#endif // QT_NO_TABBAR
+
+#ifndef QT_NO_COMBOBOX
+/*!
+ \class QAccessibleComboBox
+ \brief The QAccessibleComboBox class implements the QAccessibleInterface for editable and read-only combo boxes.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ \enum QAccessibleComboBox::ComboBoxElements
+
+ \internal
+
+ \value ComboBoxSelf
+ \value CurrentText
+ \value OpenList
+ \value PopupList
+*/
+
+/*!
+ Constructs a QAccessibleComboBox object for \a w.
+*/
+QAccessibleComboBox::QAccessibleComboBox(QWidget *w)
+: QAccessibleWidgetEx(w, ComboBox)
+{
+ Q_ASSERT(comboBox());
+}
+
+/*!
+ Returns the combobox.
+*/
+QComboBox *QAccessibleComboBox::comboBox() const
+{
+ return qobject_cast<QComboBox*>(object());
+}
+
+/*! \reimp */
+QRect QAccessibleComboBox::rect(int child) const
+{
+ QPoint tp;
+ QStyle::SubControl sc;
+ QRect r;
+ switch (child) {
+ case CurrentText:
+ if (comboBox()->isEditable()) {
+ tp = comboBox()->lineEdit()->mapToGlobal(QPoint(0,0));
+ r = comboBox()->lineEdit()->rect();
+ sc = QStyle::SC_None;
+ } else {
+ tp = comboBox()->mapToGlobal(QPoint(0,0));
+ sc = QStyle::SC_ComboBoxEditField;
+ }
+ break;
+ case OpenList:
+ tp = comboBox()->mapToGlobal(QPoint(0,0));
+ sc = QStyle::SC_ComboBoxArrow;
+ break;
+ default:
+ return QAccessibleWidgetEx::rect(child);
+ }
+
+ if (sc != QStyle::SC_None) {
+ QStyleOptionComboBox option;
+ option.initFrom(comboBox());
+ r = comboBox()->style()->subControlRect(QStyle::CC_ComboBox, &option, sc, comboBox());
+ }
+ return QRect(tp.x() + r.x(), tp.y() + r.y(), r.width(), r.height());
+}
+
+/*! \reimp */
+int QAccessibleComboBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ if (entry > ComboBoxSelf) switch (rel) {
+ case Child:
+ if (entry < PopupList)
+ return entry;
+ if (entry == PopupList) {
+ QAbstractItemView *view = comboBox()->view();
+ QWidget *parent = view ? view->parentWidget() : 0;
+ *target = QAccessible::queryAccessibleInterface(parent);
+ return *target ? 0 : -1;
+ }
+ case QAccessible::Left:
+ return entry == OpenList ? CurrentText : -1;
+ case QAccessible::Right:
+ return entry == CurrentText ? OpenList : -1;
+ case QAccessible::Up:
+ return -1;
+ case QAccessible::Down:
+ return -1;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::navigate(rel, entry, target);
+}
+
+/*! \reimp */
+int QAccessibleComboBox::childCount() const
+{
+ return comboBox()->view() ? PopupList : OpenList;
+}
+
+/*! \reimp */
+int QAccessibleComboBox::childAt(int x, int y) const
+{
+ if (!comboBox()->isVisible())
+ return -1;
+ QPoint gp = widget()->mapToGlobal(QPoint(0, 0));
+ if (!QRect(gp.x(), gp.y(), widget()->width(), widget()->height()).contains(x, y))
+ return -1;
+
+ // a complex control
+ for (int i = 1; i < PopupList; ++i) {
+ if (rect(i).contains(x, y))
+ return i;
+ }
+ return 0;
+}
+
+/*! \reimp */
+int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const
+{
+ QObject *viewParent = comboBox()->view() ? comboBox()->view()->parentWidget() : 0;
+ if (child->object() == viewParent)
+ return PopupList;
+ return -1;
+}
+
+/*! \reimp */
+QString QAccessibleComboBox::text(Text t, int child) const
+{
+ QString str;
+
+ switch (t) {
+ case Name:
+ if (child == OpenList)
+ str = QComboBox::tr("Open");
+ else
+ str = QAccessibleWidgetEx::text(t, 0);
+ break;
+#ifndef QT_NO_SHORTCUT
+ case Accelerator:
+ if (child == OpenList)
+ str = (QString)QKeySequence(Qt::Key_Down);
+ // missing break?
+#endif
+ case Value:
+ if (comboBox()->isEditable())
+ str = comboBox()->lineEdit()->text();
+ else
+ str = comboBox()->currentText();
+ break;
+ default:
+ break;
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, 0);
+ return str;
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleComboBox::role(int child) const
+{
+ switch (child) {
+ case CurrentText:
+ if (comboBox()->isEditable())
+ return EditableText;
+ return StaticText;
+ case OpenList:
+ return PushButton;
+ case PopupList:
+ return List;
+ default:
+ return ComboBox;
+ }
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleComboBox::state(int /*child*/) const
+{
+ return QAccessibleWidgetEx::state(0);
+}
+
+/*! \reimp */
+bool QAccessibleComboBox::doAction(int action, int child, const QVariantList &)
+{
+ if (child == 2 && (action == DefaultAction || action == Press)) {
+ if (comboBox()->view()->isVisible()) {
+ comboBox()->hidePopup();
+ } else {
+ comboBox()->showPopup();
+ }
+ return true;
+ }
+ return false;
+}
+
+QString QAccessibleComboBox::actionText(int action, Text t, int child) const
+{
+ QString text;
+ if (child == 2 && t == Name && (action == DefaultAction || action == Press))
+ text = comboBox()->view()->isVisible() ? QComboBox::tr("Close") : QComboBox::tr("Open");
+ return text;
+}
+#endif // QT_NO_COMBOBOX
+
+static inline void removeInvisibleWidgetsFromList(QWidgetList *list)
+{
+ if (!list || list->isEmpty())
+ return;
+
+ for (int i = 0; i < list->count(); ++i) {
+ QWidget *widget = list->at(i);
+ if (!widget->isVisible())
+ list->removeAt(i);
+ }
+}
+
+#ifndef QT_NO_SCROLLAREA
+// ======================= QAccessibleAbstractScrollArea =======================
+QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget)
+ : QAccessibleWidgetEx(widget, Client)
+{
+ Q_ASSERT(qobject_cast<QAbstractScrollArea *>(widget));
+}
+
+QString QAccessibleAbstractScrollArea::text(Text textType, int child) const
+{
+ if (child == Self)
+ return QAccessibleWidgetEx::text(textType, 0);
+ QWidgetList children = accessibleChildren();
+ if (child < 1 || child > children.count())
+ return QString();
+ QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1));
+ if (!childInterface)
+ return QString();
+ QString string = childInterface->text(textType, 0);
+ delete childInterface;
+ return string;
+}
+
+void QAccessibleAbstractScrollArea::setText(Text textType, int child, const QString &text)
+{
+ if (text.isEmpty())
+ return;
+ if (child == 0) {
+ QAccessibleWidgetEx::setText(textType, 0, text);
+ return;
+ }
+ QWidgetList children = accessibleChildren();
+ if (child < 1 || child > children.count())
+ return;
+ QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1));
+ if (!childInterface)
+ return;
+ childInterface->setText(textType, 0, text);
+ delete childInterface;
+}
+
+QAccessible::State QAccessibleAbstractScrollArea::state(int child) const
+{
+ if (child == Self)
+ return QAccessibleWidgetEx::state(child);
+ QWidgetList children = accessibleChildren();
+ if (child < 1 || child > children.count())
+ return QAccessibleWidgetEx::state(Self);
+ QAccessibleInterface *childInterface = queryAccessibleInterface(children.at(child - 1));
+ if (!childInterface)
+ return QAccessibleWidgetEx::state(Self);
+ QAccessible::State returnState = childInterface->state(0);
+ delete childInterface;
+ return returnState;
+}
+
+QVariant QAccessibleAbstractScrollArea::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+int QAccessibleAbstractScrollArea::childCount() const
+{
+ return accessibleChildren().count();
+}
+
+int QAccessibleAbstractScrollArea::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (!child || !child->object())
+ return -1;
+ int index = accessibleChildren().indexOf(qobject_cast<QWidget *>(child->object()));
+ if (index >= 0)
+ return ++index;
+ return -1;
+}
+
+bool QAccessibleAbstractScrollArea::isValid() const
+{
+ return (QAccessibleWidgetEx::isValid() && abstractScrollArea() && abstractScrollArea()->viewport());
+}
+
+int QAccessibleAbstractScrollArea::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ if (!target)
+ return -1;
+
+ *target = 0;
+
+ QWidget *targetWidget = 0;
+ QWidget *entryWidget = 0;
+
+ if (relation == Child ||
+ relation == Left || relation == Up || relation == Right || relation == Down) {
+ QWidgetList children = accessibleChildren();
+ if (entry < 0 || entry > children.count())
+ return -1;
+
+ if (entry == Self)
+ entryWidget = abstractScrollArea();
+ else
+ entryWidget = children.at(entry - 1);
+ AbstractScrollAreaElement entryElement = elementType(entryWidget);
+
+ // Not one of the most beautiful switches I've ever seen, but I believe it has
+ // to be like this since each case need special handling.
+ // It might be possible to make it more general, but I'll leave that as an exercise
+ // to the reader. :-)
+ switch (relation) {
+ case Child:
+ if (entry > 0)
+ targetWidget = children.at(entry - 1);
+ break;
+ case Left:
+ if (entry < 1)
+ break;
+ switch (entryElement) {
+ case Viewport:
+ if (!isLeftToRight())
+ targetWidget = abstractScrollArea()->verticalScrollBar();
+ break;
+ case HorizontalContainer:
+ if (!isLeftToRight())
+ targetWidget = abstractScrollArea()->cornerWidget();
+ break;
+ case VerticalContainer:
+ if (isLeftToRight())
+ targetWidget = abstractScrollArea()->viewport();
+ break;
+ case CornerWidget:
+ if (isLeftToRight())
+ targetWidget = abstractScrollArea()->horizontalScrollBar();
+ break;
+ default:
+ break;
+ }
+ break;
+ case Right:
+ if (entry < 1)
+ break;
+ switch (entryElement) {
+ case Viewport:
+ if (isLeftToRight())
+ targetWidget = abstractScrollArea()->verticalScrollBar();
+ break;
+ case HorizontalContainer:
+ targetWidget = abstractScrollArea()->cornerWidget();
+ break;
+ case VerticalContainer:
+ if (!isLeftToRight())
+ targetWidget = abstractScrollArea()->viewport();
+ break;
+ case CornerWidget:
+ if (!isLeftToRight())
+ targetWidget = abstractScrollArea()->horizontalScrollBar();
+ break;
+ default:
+ break;
+ }
+ break;
+ case Up:
+ if (entry < 1)
+ break;
+ switch (entryElement) {
+ case HorizontalContainer:
+ targetWidget = abstractScrollArea()->viewport();
+ break;
+ case CornerWidget:
+ targetWidget = abstractScrollArea()->verticalScrollBar();
+ break;
+ default:
+ break;
+ }
+ break;
+ case Down:
+ if (entry < 1)
+ break;
+ switch (entryElement) {
+ case Viewport:
+ targetWidget = abstractScrollArea()->horizontalScrollBar();
+ break;
+ case VerticalContainer:
+ targetWidget = abstractScrollArea()->cornerWidget();
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ } else {
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+
+ if (qobject_cast<const QScrollBar *>(targetWidget))
+ targetWidget = targetWidget->parentWidget();
+ *target = QAccessible::queryAccessibleInterface(targetWidget);
+ return *target ? 0: -1;
+}
+
+QRect QAccessibleAbstractScrollArea::rect(int child) const
+{
+ if (!abstractScrollArea()->isVisible())
+ return QRect();
+ if (child == Self)
+ return QAccessibleWidgetEx::rect(child);
+ QWidgetList children = accessibleChildren();
+ if (child < 1 || child > children.count())
+ return QRect();
+ const QWidget *childWidget = children.at(child - 1);
+ if (!childWidget->isVisible())
+ return QRect();
+ return QRect(childWidget->mapToGlobal(QPoint(0, 0)), childWidget->size());
+}
+
+int QAccessibleAbstractScrollArea::childAt(int x, int y) const
+{
+ if (!abstractScrollArea()->isVisible())
+ return -1;
+#if 0
+ const QRect globalSelfGeometry = rect(Self);
+ if (!globalSelfGeometry.isValid() || !globalSelfGeometry.contains(QPoint(x, y)))
+ return -1;
+ const QWidgetList children = accessibleChildren();
+ for (int i = 0; i < children.count(); ++i) {
+ const QWidget *child = children.at(i);
+ const QRect globalChildGeometry = QRect(child->mapToGlobal(QPoint(0, 0)), child->size());
+ if (globalChildGeometry.contains(QPoint(x, y))) {
+ return ++i;
+ }
+ }
+ return 0;
+#else
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(x, y))
+ return i;
+ }
+ return -1;
+#endif
+}
+
+QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const
+{
+ return static_cast<QAbstractScrollArea *>(object());
+}
+
+QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const
+{
+ QWidgetList children;
+
+ // Viewport.
+ QWidget * viewport = abstractScrollArea()->viewport();
+ if (viewport)
+ children.append(viewport);
+
+ // Horizontal scrollBar container.
+ QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar();
+ if (horizontalScrollBar && horizontalScrollBar->isVisible()) {
+ children.append(horizontalScrollBar->parentWidget());
+ }
+
+ // Vertical scrollBar container.
+ QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar();
+ if (verticalScrollBar && verticalScrollBar->isVisible()) {
+ children.append(verticalScrollBar->parentWidget());
+ }
+
+ // CornerWidget.
+ QWidget *cornerWidget = abstractScrollArea()->cornerWidget();
+ if (cornerWidget && cornerWidget->isVisible())
+ children.append(cornerWidget);
+
+ return children;
+}
+
+QAccessibleAbstractScrollArea::AbstractScrollAreaElement
+QAccessibleAbstractScrollArea::elementType(QWidget *widget) const
+{
+ if (!widget)
+ return Undefined;
+
+ if (widget == abstractScrollArea())
+ return Self;
+ if (widget == abstractScrollArea()->viewport())
+ return Viewport;
+ if (widget->objectName() == QLatin1String("qt_scrollarea_hcontainer"))
+ return HorizontalContainer;
+ if (widget->objectName() == QLatin1String("qt_scrollarea_vcontainer"))
+ return VerticalContainer;
+ if (widget == abstractScrollArea()->cornerWidget())
+ return CornerWidget;
+
+ return Undefined;
+}
+
+bool QAccessibleAbstractScrollArea::isLeftToRight() const
+{
+ return abstractScrollArea()->isLeftToRight();
+}
+
+// ======================= QAccessibleScrollArea ===========================
+QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget)
+ : QAccessibleAbstractScrollArea(widget)
+{
+ Q_ASSERT(qobject_cast<QScrollArea *>(widget));
+}
+#endif // QT_NO_SCROLLAREA
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h
new file mode 100644
index 0000000000..b5ba13941d
--- /dev/null
+++ b/src/plugins/accessible/widgets/complexwidgets.h
@@ -0,0 +1,293 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COMPLEXWIDGETS_H
+#define COMPLEXWIDGETS_H
+
+#include <QtCore/qpointer.h>
+#include <QtGui/qaccessiblewidget.h>
+#include <QtGui/qabstractitemview.h>
+#include <QtGui/qaccessible2.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QAbstractButton;
+class QHeaderView;
+class QTabBar;
+class QComboBox;
+class QTitleBar;
+class QAbstractScrollArea;
+class QScrollArea;
+
+#ifndef QT_NO_SCROLLAREA
+class QAccessibleAbstractScrollArea : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleAbstractScrollArea(QWidget *widget);
+
+ enum AbstractScrollAreaElement {
+ Self = 0,
+ Viewport,
+ HorizontalContainer,
+ VerticalContainer,
+ CornerWidget,
+ Undefined
+ };
+
+ QString text(Text textType, int child) const;
+ void setText(Text textType, int child, const QString &text);
+ State state(int child) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ bool isValid() const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+ QRect rect(int child) const;
+ int childAt(int x, int y) const;
+
+//protected:
+ QAbstractScrollArea *abstractScrollArea() const;
+
+private:
+ QWidgetList accessibleChildren() const;
+ AbstractScrollAreaElement elementType(QWidget *widget) const;
+ bool isLeftToRight() const;
+};
+
+class QAccessibleScrollArea : public QAccessibleAbstractScrollArea
+{
+public:
+ explicit QAccessibleScrollArea(QWidget *widget);
+};
+
+#endif // QT_NO_SCROLLAREA
+
+#ifndef QT_NO_ITEMVIEWS
+class QAccessibleHeader : public QAccessibleWidgetEx
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleHeader(QWidget *w);
+
+ int childCount() const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+protected:
+ QHeaderView *header() const;
+};
+
+class QAccessibleItemRow: public QAccessibleInterface
+{
+ friend class QAccessibleItemView;
+public:
+ QAccessibleItemRow(QAbstractItemView *view, const QModelIndex &index = QModelIndex(), bool isHeader = false);
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ void setText(Text t, int child, const QString &text);
+ bool isValid() const;
+ QObject *object() const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *) const;
+ QList<QModelIndex> children() const;
+
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+ int childAt(int x, int y) const;
+ int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
+
+ int userActionCount(int child) const;
+ QString actionText(int action, Text t, int child) const;
+ bool doAction(int action, int child, const QVariantList &params = QVariantList());
+
+ QModelIndex childIndex(int child) const;
+
+ QHeaderView *horizontalHeader() const; //used by QAccessibleItemView
+private:
+ static QAbstractItemView::CursorAction toCursorAction(Relation rel);
+ int logicalFromChild(QHeaderView *header, int child) const;
+ int treeLevel() const;
+ QHeaderView *verticalHeader() const;
+ QString text_helper(int child) const;
+
+ QPersistentModelIndex row;
+ QPointer<QAbstractItemView> view;
+ bool m_header;
+};
+
+class QAccessibleItemView: public QAccessibleAbstractScrollArea, public QAccessibleTableInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleItemView(QWidget *w);
+
+ QObject *object() const;
+ Role role(int child) const;
+ State state(int child) const;
+ QRect rect(int child) const;
+ int childAt(int x, int y) const;
+ int childCount() const;
+ QString text(Text t, int child) const;
+ void setText(Text t, int child, const QString &text);
+ int indexOfChild(const QAccessibleInterface *iface) const;
+
+ QModelIndex childIndex(int child) const;
+ int entryFromIndex(const QModelIndex &index) const;
+ bool isValid() const;
+ int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
+
+ QAccessibleInterface *accessibleAt(int row, int column);
+ QAccessibleInterface *caption();
+ int childIndex(int rowIndex, int columnIndex);
+ QString columnDescription(int column);
+ int columnSpan(int row, int column);
+ QAccessibleInterface *columnHeader();
+ int columnIndex(int childIndex);
+ int columnCount();
+ int rowCount();
+ int selectedColumnCount();
+ int selectedRowCount();
+ QString rowDescription(int row);
+ int rowSpan(int row, int column);
+ QAccessibleInterface *rowHeader();
+ int rowIndex(int childIndex);
+ int selectedRows(int maxRows, QList<int> *rows);
+ int selectedColumns(int maxColumns, QList<int> *columns);
+ QAccessibleInterface *summary();
+ bool isColumnSelected(int column);
+ bool isRowSelected(int row);
+ bool isSelected(int row, int column);
+ void selectRow(int row);
+ void selectColumn(int column);
+ void unselectRow(int row);
+ void unselectColumn(int column);
+ void cellAtIndex(int index, int *row, int *column, int *rowSpan,
+ int *columnSpan, bool *isSelected);
+
+ QHeaderView *horizontalHeader() const;
+ QHeaderView *verticalHeader() const;
+ bool isValidChildRole(QAccessible::Role role) const;
+
+protected:
+ QAbstractItemView *itemView() const;
+ QModelIndex index(int row, int column) const;
+
+private:
+ inline bool atViewport() const {
+ return atVP;
+ };
+ QAccessible::Role expectedRoleOfChildren() const;
+
+ bool atVP;
+};
+
+#endif
+
+#ifndef QT_NO_TABBAR
+class QAccessibleTabBar : public QAccessibleWidgetEx
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleTabBar(QWidget *w);
+
+ int childCount() const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ bool doAction(int action, int child, const QVariantList &params);
+ bool setSelected(int child, bool on, bool extend);
+ QVector<int> selection() const;
+
+protected:
+ QTabBar *tabBar() const;
+
+private:
+ QAbstractButton *button(int child) const;
+};
+#endif // QT_NO_TABBAR
+
+#ifndef QT_NO_COMBOBOX
+class QAccessibleComboBox : public QAccessibleWidgetEx
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleComboBox(QWidget *w);
+
+ enum ComboBoxElements {
+ ComboBoxSelf = 0,
+ CurrentText,
+ OpenList,
+ PopupList
+ };
+
+ int childCount() const;
+ int childAt(int x, int y) const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
+
+ QString text(Text t, int child) const;
+ QRect rect(int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ bool doAction(int action, int child, const QVariantList &params);
+ QString actionText(int action, Text t, int child) const;
+
+protected:
+ QComboBox *comboBox() const;
+};
+#endif // QT_NO_COMBOBOX
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+#endif // COMPLEXWIDGETS_H
diff --git a/src/plugins/accessible/widgets/main.cpp b/src/plugins/accessible/widgets/main.cpp
new file mode 100644
index 0000000000..c73702edad
--- /dev/null
+++ b/src/plugins/accessible/widgets/main.cpp
@@ -0,0 +1,341 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblewidgets.h"
+#include "qaccessiblemenu.h"
+#include "simplewidgets.h"
+#include "rangecontrols.h"
+#include "complexwidgets.h"
+
+#include <qaccessibleplugin.h>
+#include <qplugin.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qvariant.h>
+#include <qaccessible.h>
+
+#ifndef QT_NO_ACCESSIBILITY
+
+QT_BEGIN_NAMESPACE
+
+class AccessibleFactory : public QAccessiblePlugin
+{
+public:
+ AccessibleFactory();
+
+ QStringList keys() const;
+ QAccessibleInterface *create(const QString &classname, QObject *object);
+};
+
+AccessibleFactory::AccessibleFactory()
+{
+}
+
+QStringList AccessibleFactory::keys() const
+{
+ QStringList list;
+#ifndef QT_NO_LINEEDIT
+ list << QLatin1String("QLineEdit");
+#endif
+#ifndef QT_NO_COMBOBOX
+ list << QLatin1String("QComboBox");
+#endif
+#ifndef QT_NO_SPINBOX
+ list << QLatin1String("QAbstractSpinBox");
+ list << QLatin1String("QSpinBox");
+ list << QLatin1String("QDoubleSpinBox");
+#endif
+#ifndef QT_NO_SCROLLBAR
+ list << QLatin1String("QScrollBar");
+#endif
+#ifndef QT_NO_SLIDER
+ list << QLatin1String("QSlider");
+#endif
+ list << QLatin1String("QAbstractSlider");
+#ifndef QT_NO_TOOLBUTTON
+ list << QLatin1String("QToolButton");
+#endif
+ list << QLatin1String("QCheckBox");
+ list << QLatin1String("QRadioButton");
+ list << QLatin1String("QPushButton");
+ list << QLatin1String("QAbstractButton");
+ list << QLatin1String("QDialog");
+ list << QLatin1String("QMessageBox");
+ list << QLatin1String("QMainWindow");
+ list << QLatin1String("QLabel");
+ list << QLatin1String("QLCDNumber");
+ list << QLatin1String("QGroupBox");
+ list << QLatin1String("QStatusBar");
+ list << QLatin1String("QProgressBar");
+ list << QLatin1String("QMenuBar");
+ list << QLatin1String("Q3PopupMenu");
+ list << QLatin1String("QMenu");
+ list << QLatin1String("QHeaderView");
+ list << QLatin1String("QTabBar");
+ list << QLatin1String("QToolBar");
+ list << QLatin1String("QWorkspaceChild");
+ list << QLatin1String("QSizeGrip");
+ list << QLatin1String("QAbstractItemView");
+ list << QLatin1String("QWidget");
+#ifndef QT_NO_SPLITTER
+ list << QLatin1String("QSplitter");
+ list << QLatin1String("QSplitterHandle");
+#endif
+#ifndef QT_NO_TEXTEDIT
+ list << QLatin1String("QTextEdit");
+#endif
+ list << QLatin1String("QTipLabel");
+ list << QLatin1String("QFrame");
+ list << QLatin1String("QStackedWidget");
+ list << QLatin1String("QToolBox");
+ list << QLatin1String("QMdiArea");
+ list << QLatin1String("QMdiSubWindow");
+ list << QLatin1String("QWorkspace");
+ list << QLatin1String("QDialogButtonBox");
+#ifndef QT_NO_DIAL
+ list << QLatin1String("QDial");
+#endif
+#ifndef QT_NO_RUBBERBAND
+ list << QLatin1String("QRubberBand");
+#endif
+#ifndef QT_NO_TEXTBROWSER
+ list << QLatin1String("QTextBrowser");
+#endif
+#ifndef QT_NO_SCROLLAREA
+ list << QLatin1String("QAbstractScrollArea");
+ list << QLatin1String("QScrollArea");
+#endif
+#ifndef QT_NO_CALENDARWIDGET
+ list << QLatin1String("QCalendarWidget");
+#endif
+
+#ifndef QT_NO_DOCKWIDGET
+ list << QLatin1String("QDockWidget");
+#endif
+ return list;
+}
+
+QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
+{
+ QAccessibleInterface *iface = 0;
+ if (!object || !object->isWidgetType())
+ return iface;
+ QWidget *widget = static_cast<QWidget*>(object);
+
+ if (false) {
+#ifndef QT_NO_LINEEDIT
+ } else if (classname == QLatin1String("QLineEdit")) {
+ iface = new QAccessibleLineEdit(widget);
+#endif
+#ifndef QT_NO_COMBOBOX
+ } else if (classname == QLatin1String("QComboBox")) {
+ iface = new QAccessibleComboBox(widget);
+#endif
+#ifndef QT_NO_SPINBOX
+ } else if (classname == QLatin1String("QAbstractSpinBox")) {
+ iface = new QAccessibleAbstractSpinBox(widget);
+ } else if (classname == QLatin1String("QSpinBox")) {
+ iface = new QAccessibleSpinBox(widget);
+ } else if (classname == QLatin1String("QDoubleSpinBox")) {
+ iface = new QAccessibleDoubleSpinBox(widget);
+#endif
+#ifndef QT_NO_SCROLLBAR
+ } else if (classname == QLatin1String("QScrollBar")) {
+ iface = new QAccessibleScrollBar(widget);
+#endif
+ } else if (classname == QLatin1String("QAbstractSlider")) {
+ iface = new QAccessibleAbstractSlider(widget);
+#ifndef QT_NO_SLIDER
+ } else if (classname == QLatin1String("QSlider")) {
+ iface = new QAccessibleSlider(widget);
+#endif
+#ifndef QT_NO_TOOLBUTTON
+ } else if (classname == QLatin1String("QToolButton")) {
+ Role role = NoRole;
+#ifndef QT_NO_MENU
+ QToolButton *tb = qobject_cast<QToolButton*>(widget);
+ if (!tb->menu())
+ role = tb->isCheckable() ? CheckBox : PushButton;
+ else if (!tb->popupMode() != QToolButton::DelayedPopup)
+ role = ButtonDropDown;
+ else
+#endif
+ role = ButtonMenu;
+ iface = new QAccessibleToolButton(widget, role);
+#endif // QT_NO_TOOLBUTTON
+ } else if (classname == QLatin1String("QCheckBox")) {
+ iface = new QAccessibleButton(widget, CheckBox);
+ } else if (classname == QLatin1String("QRadioButton")) {
+ iface = new QAccessibleButton(widget, RadioButton);
+ } else if (classname == QLatin1String("QPushButton")) {
+ Role role = NoRole;
+ QPushButton *pb = qobject_cast<QPushButton*>(widget);
+#ifndef QT_NO_MENU
+ if (pb->menu())
+ role = ButtonMenu;
+ else
+#endif
+ if (pb->isCheckable())
+ role = CheckBox;
+ else
+ role = PushButton;
+ iface = new QAccessibleButton(widget, role);
+ } else if (classname == QLatin1String("QAbstractButton")) {
+ iface = new QAccessibleButton(widget, PushButton);
+ } else if (classname == QLatin1String("QDialog")) {
+ iface = new QAccessibleWidgetEx(widget, Dialog);
+ } else if (classname == QLatin1String("QMessageBox")) {
+ iface = new QAccessibleWidgetEx(widget, AlertMessage);
+#ifndef QT_NO_MAINWINDOW
+ } else if (classname == QLatin1String("QMainWindow")) {
+ iface = new QAccessibleMainWindow(widget);
+#endif
+ } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
+ iface = new QAccessibleDisplay(widget);
+ } else if (classname == QLatin1String("QGroupBox")) {
+ iface = new QAccessibleDisplay(widget, Grouping);
+ } else if (classname == QLatin1String("QStatusBar")) {
+ iface = new QAccessibleWidgetEx(widget, StatusBar);
+#ifndef QT_NO_PROGRESSBAR
+ } else if (classname == QLatin1String("QProgressBar")) {
+ iface = new QAccessibleProgressBar(widget);
+#endif
+ } else if (classname == QLatin1String("QToolBar")) {
+ iface = new QAccessibleWidgetEx(widget, ToolBar, widget->windowTitle());
+#ifndef QT_NO_MENUBAR
+ } else if (classname == QLatin1String("QMenuBar")) {
+ iface = new QAccessibleMenuBar(widget);
+#endif
+#ifndef QT_NO_MENU
+ } else if (classname == QLatin1String("QMenu")) {
+ iface = new QAccessibleMenu(widget);
+ } else if (classname == QLatin1String("Q3PopupMenu")) {
+ iface = new QAccessibleMenu(widget);
+#endif
+#ifndef QT_NO_ITEMVIEWS
+ } else if (classname == QLatin1String("QHeaderView")) {
+ iface = new QAccessibleHeader(widget);
+ } else if (classname == QLatin1String("QAbstractItemView")) {
+ iface = new QAccessibleItemView(widget);
+ } else if (classname == QLatin1String("QWidget")
+ && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
+ && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
+ iface = new QAccessibleItemView(widget);
+#endif
+#ifndef QT_NO_TABBAR
+ } else if (classname == QLatin1String("QTabBar")) {
+ iface = new QAccessibleTabBar(widget);
+#endif
+ } else if (classname == QLatin1String("QWorkspaceChild")) {
+ iface = new QAccessibleWidgetEx(widget, Window);
+ } else if (classname == QLatin1String("QSizeGrip")) {
+ iface = new QAccessibleWidgetEx(widget, Grip);
+#ifndef QT_NO_SPLITTER
+ } else if (classname == QLatin1String("QSplitter")) {
+ iface = new QAccessibleWidgetEx(widget, Splitter);
+ } else if (classname == QLatin1String("QSplitterHandle")) {
+ iface = new QAccessibleWidgetEx(widget, Grip);
+#endif
+#ifndef QT_NO_TEXTEDIT
+ } else if (classname == QLatin1String("QTextEdit")) {
+ iface = new QAccessibleTextEdit(widget);
+#endif
+ } else if (classname == QLatin1String("QTipLabel")) {
+ iface = new QAccessibleDisplay(widget, ToolTip);
+ } else if (classname == QLatin1String("QFrame")) {
+ iface = new QAccessibleWidget(widget, Border);
+#ifndef QT_NO_STACKEDWIDGET
+ } else if (classname == QLatin1String("QStackedWidget")) {
+ iface = new QAccessibleStackedWidget(widget);
+#endif
+#ifndef QT_NO_TOOLBOX
+ } else if (classname == QLatin1String("QToolBox")) {
+ iface = new QAccessibleToolBox(widget);
+#endif
+#ifndef QT_NO_MDIAREA
+ } else if (classname == QLatin1String("QMdiArea")) {
+ iface = new QAccessibleMdiArea(widget);
+ } else if (classname == QLatin1String("QMdiSubWindow")) {
+ iface = new QAccessibleMdiSubWindow(widget);
+#endif
+#ifndef QT_NO_WORKSPACE
+ } else if (classname == QLatin1String("QWorkspace")) {
+ iface = new QAccessibleWorkspace(widget);
+#endif
+ } else if (classname == QLatin1String("QDialogButtonBox")) {
+ iface = new QAccessibleDialogButtonBox(widget);
+#ifndef QT_NO_DIAL
+ } else if (classname == QLatin1String("QDial")) {
+ iface = new QAccessibleDial(widget);
+#endif
+#ifndef QT_NO_RUBBERBAND
+ } else if (classname == QLatin1String("QRubberBand")) {
+ iface = new QAccessibleWidgetEx(widget, QAccessible::Border);
+#endif
+#ifndef QT_NO_TEXTBROWSER
+ } else if (classname == QLatin1String("QTextBrowser")) {
+ iface = new QAccessibleTextBrowser(widget);
+#endif
+#ifndef QT_NO_SCROLLAREA
+ } else if (classname == QLatin1String("QAbstractScrollArea")) {
+ iface = new QAccessibleAbstractScrollArea(widget);
+ } else if (classname == QLatin1String("QScrollArea")) {
+ iface = new QAccessibleScrollArea(widget);
+#endif
+#ifndef QT_NO_CALENDARWIDGET
+ } else if (classname == QLatin1String("QCalendarWidget")) {
+ iface = new QAccessibleCalendarWidget(widget);
+#endif
+#ifndef QT_NO_DOCKWIDGET
+ } else if (classname == QLatin1String("QDockWidget")) {
+ iface = new QAccessibleDockWidget(widget);
+#endif
+ }
+
+ return iface;
+}
+
+Q_EXPORT_STATIC_PLUGIN(AccessibleFactory)
+Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
new file mode 100644
index 0000000000..6d8a358d5c
--- /dev/null
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
@@ -0,0 +1,678 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblemenu.h"
+
+#include <qmenu.h>
+#include <qmenubar.h>
+#include <QtGui/QAction>
+#include <qstyle.h>
+
+#ifndef QT_NO_ACCESSIBILITY
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_MENU
+
+QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
+QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
+
+QAccessibleMenu::QAccessibleMenu(QWidget *w)
+: QAccessibleWidgetEx(w)
+{
+ Q_ASSERT(menu());
+}
+
+QMenu *QAccessibleMenu::menu() const
+{
+ return qobject_cast<QMenu*>(object());
+}
+
+int QAccessibleMenu::childCount() const
+{
+ return menu()->actions().count();
+}
+
+QRect QAccessibleMenu::rect(int child) const
+{
+ if (!child || child > childCount())
+ return QAccessibleWidgetEx::rect(child);
+
+ QRect r = menu()->actionGeometry(menu()->actions()[child - 1]);
+ QPoint tlp = menu()->mapToGlobal(QPoint(0,0));
+
+ return QRect(tlp.x() + r.x(), tlp.y() + r.y(), r.width(), r.height());
+}
+
+int QAccessibleMenu::childAt(int x, int y) const
+{
+ QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y)));
+ if(act && act->isSeparator())
+ act = 0;
+ return menu()->actions().indexOf(act) + 1;
+}
+
+QString QAccessibleMenu::text(Text t, int child) const
+{
+ QString tx = QAccessibleWidgetEx::text(t, child);
+ if (tx.size())
+ return tx;
+
+ switch (t) {
+ case Name:
+ if (!child)
+ return menu()->windowTitle();
+ return qt_accStripAmp(menu()->actions().at(child-1)->text());
+ case Help:
+ return child ? menu()->actions().at(child-1)->whatsThis() : tx;
+#ifndef QT_NO_SHORTCUT
+ case Accelerator:
+ return child ? static_cast<QString>(menu()->actions().at(child-1)->shortcut()) : tx;
+#endif
+ default:
+ break;
+ }
+ return tx;
+}
+
+QAccessible::Role QAccessibleMenu::role(int child) const
+{
+ if (!child)
+ return PopupMenu;
+
+ QAction *action = menu()->actions()[child-1];
+ if (action && action->isSeparator())
+ return Separator;
+ return MenuItem;
+}
+
+QAccessible::State QAccessibleMenu::state(int child) const
+{
+ State s = QAccessibleWidgetEx::state(child);
+ if (!child)
+ return s;
+
+ QAction *action = menu()->actions()[child-1];
+ if (!action)
+ return s;
+
+ if (menu()->style()->styleHint(QStyle::SH_Menu_MouseTracking))
+ s |= HotTracked;
+ if (action->isSeparator() || !action->isEnabled())
+ s |= Unavailable;
+ if (action->isChecked())
+ s |= Checked;
+ if (menu()->activeAction() == action)
+ s |= Focused;
+
+ return s;
+}
+
+QString QAccessibleMenu::actionText(int action, QAccessible::Text text, int child) const
+{
+ if (action == QAccessible::DefaultAction && child && text == QAccessible::Name) {
+ QAction *a = menu()->actions().value(child-1, 0);
+ if (!a || a->isSeparator())
+ return QString();
+ if (a->menu()) {
+ if (a->menu()->isVisible())
+ return QMenu::tr("Close");
+ return QMenu::tr("Open");
+ }
+ return QMenu::tr("Execute");
+ }
+
+ return QAccessibleWidgetEx::actionText(action, text, child);
+}
+
+bool QAccessibleMenu::doAction(int act, int child, const QVariantList &)
+{
+ if (!child || act != QAccessible::DefaultAction)
+ return false;
+
+ QAction *action = menu()->actions().value(child-1, 0);
+ if (!action || !action->isEnabled())
+ return false;
+
+ if (action->menu() && action->menu()->isVisible())
+ action->menu()->hide();
+ else
+ menu()->setActiveAction(action);
+ return true;
+}
+
+int QAccessibleMenu::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ int ret = -1;
+ if (entry < 0) {
+ *target = 0;
+ return ret;
+ }
+
+ if (relation == Self || entry == 0) {
+ *target = new QAccessibleMenu(menu());
+ return 0;
+ }
+
+ switch (relation) {
+ case Child:
+ if (entry <= childCount()) {
+ *target = new QAccessibleMenuItem(menu(), menu()->actions().at( entry - 1 ));
+ ret = 0;
+ }
+ break;
+ case Ancestor: {
+ QAccessibleInterface *iface;
+ QWidget *parent = menu()->parentWidget();
+ if (qobject_cast<QMenu*>(parent) || qobject_cast<QMenuBar*>(parent)) {
+ iface = new QAccessibleMenuItem(parent, menu()->menuAction());
+ if (entry == 1) {
+ *target = iface;
+ ret = 0;
+ } else {
+ ret = iface->navigate(Ancestor, entry - 1, target);
+ delete iface;
+ }
+ } else {
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+ break;}
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+
+
+ if (ret == -1)
+ *target = 0;
+
+ return ret;
+
+}
+
+int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child ) const
+{
+ int index = -1;
+ Role r = child->role(0);
+ if ((r == MenuItem || r == Separator) && menu()) {
+ index = menu()->actions().indexOf(qobject_cast<QAction*>(child->object()));
+ if (index != -1)
+ ++index;
+ }
+ return index;
+}
+
+#ifndef QT_NO_MENUBAR
+QAccessibleMenuBar::QAccessibleMenuBar(QWidget *w)
+: QAccessibleWidgetEx(w)
+{
+ Q_ASSERT(menuBar());
+}
+
+QMenuBar *QAccessibleMenuBar::menuBar() const
+{
+ return qobject_cast<QMenuBar*>(object());
+}
+
+int QAccessibleMenuBar::childCount() const
+{
+ return menuBar()->actions().count();
+}
+
+QRect QAccessibleMenuBar::rect(int child) const
+{
+ if (!child)
+ return QAccessibleWidgetEx::rect(child);
+
+ QRect r = menuBar()->actionGeometry(menuBar()->actions()[child - 1]);
+ QPoint tlp = menuBar()->mapToGlobal(QPoint(0,0));
+ return QRect(tlp.x() + r.x(), tlp.y() + r.y(), r.width(), r.height());
+}
+
+int QAccessibleMenuBar::childAt(int x, int y) const
+{
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(x,y))
+ return i;
+ }
+ return -1;
+}
+
+int QAccessibleMenuBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ int ret = -1;
+ if (entry < 0) {
+ *target = 0;
+ return ret;
+ }
+
+ if (relation == Self || entry == 0) {
+ *target = new QAccessibleMenuBar(menuBar());
+ return 0;
+ }
+
+ switch (relation) {
+ case Child:
+ if (entry <= childCount()) {
+ *target = new QAccessibleMenuItem(menuBar(), menuBar()->actions().at( entry - 1 ));
+ ret = 0;
+ }
+ break;
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+
+
+ if (ret == -1)
+ *target = 0;
+
+ return ret;
+}
+
+int QAccessibleMenuBar::indexOfChild( const QAccessibleInterface *child ) const
+{
+ int index = -1;
+ Role r = child->role(0);
+ if ((r == MenuItem || r == Separator) && menuBar()) {
+ index = menuBar()->actions().indexOf(qobject_cast<QAction*>(child->object()));
+ if (index != -1)
+ ++index;
+ }
+ return index;
+}
+
+QString QAccessibleMenuBar::text(Text t, int child) const
+{
+ QString str;
+
+ if (child) {
+ if (QAction *action = menuBar()->actions().value(child - 1, 0)) {
+ switch (t) {
+ case Name:
+ return qt_accStripAmp(action->text());
+ case Accelerator:
+ str = qt_accHotKey(action->text());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, child);
+ return str;
+}
+
+QAccessible::Role QAccessibleMenuBar::role(int child) const
+{
+ if (!child)
+ return MenuBar;
+
+ QAction *action = menuBar()->actions()[child-1];
+ if (action && action->isSeparator())
+ return Separator;
+ return MenuItem;
+}
+
+QAccessible::State QAccessibleMenuBar::state(int child) const
+{
+ State s = QAccessibleWidgetEx::state(child);
+ if (!child)
+ return s;
+
+ QAction *action = menuBar()->actions().value(child-1, 0);
+ if (!action)
+ return s;
+
+ if (menuBar()->style()->styleHint(QStyle::SH_Menu_MouseTracking))
+ s |= HotTracked;
+ if (action->isSeparator() || !action->isEnabled())
+ s |= Unavailable;
+ if (menuBar()->activeAction() == action)
+ s |= Focused;
+
+ return s;
+}
+
+QString QAccessibleMenuBar::actionText(int action, QAccessible::Text text, int child) const
+{
+ if (action == QAccessible::DefaultAction && child && text == QAccessible::Name) {
+ QAction *a = menuBar()->actions().value(child-1, 0);
+ if (!a || a->isSeparator())
+ return QString();
+ if (a->menu()) {
+ if (a->menu()->isVisible())
+ return QMenu::tr("Close");
+ return QMenu::tr("Open");
+ }
+ return QMenu::tr("Execute");
+ }
+
+ return QAccessibleWidgetEx::actionText(action, text, child);
+}
+
+bool QAccessibleMenuBar::doAction(int act, int child, const QVariantList &)
+{
+ if (act != !child)
+ return false;
+
+ QAction *action = menuBar()->actions().value(child-1, 0);
+ if (!action || !action->isEnabled())
+ return false;
+ if (action->menu() && action->menu()->isVisible())
+ action->menu()->hide();
+ else
+ menuBar()->setActiveAction(action);
+ return true;
+}
+
+#endif // QT_NO_MENUBAR
+
+QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action) : m_action(action), m_owner(owner)
+{
+}
+
+
+QAccessibleMenuItem::~QAccessibleMenuItem()
+{}
+
+int QAccessibleMenuItem::childAt(int x, int y ) const
+{
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(x,y))
+ return i;
+ }
+ return -1;
+}
+
+int QAccessibleMenuItem::childCount() const
+{
+ return m_action->menu() ? 1 : 0;
+}
+
+QString QAccessibleMenuItem::actionText(int action, Text text, int child ) const
+{
+ if (text == Name && child == 0) {
+ switch (action) {
+ case Press:
+ case DefaultAction:
+ return QMenu::tr("Execute");
+ break;
+ default:
+ break;
+ }
+ }
+ return QString();
+}
+
+bool QAccessibleMenuItem::doAction(int action, int child, const QVariantList & /*params = QVariantList()*/ )
+{
+ if ((action == Press || action == DefaultAction) && child == 0) {
+ m_action->trigger();
+ return true;
+ }
+ return false;
+}
+
+int QAccessibleMenuItem::indexOfChild( const QAccessibleInterface * child ) const
+{
+ if (child->role(0) == PopupMenu && child->object() == m_action->menu())
+ return 1;
+
+ return -1;
+}
+
+bool QAccessibleMenuItem::isValid() const
+{
+ return m_action ? true : false;
+}
+
+int QAccessibleMenuItem::navigate(RelationFlag relation, int entry, QAccessibleInterface ** target ) const
+{
+ int ret = -1;
+ if (entry < 0) {
+ *target = 0;
+ return ret;
+ }
+
+ if (relation == Self || entry == 0) {
+ *target = new QAccessibleMenuItem(owner(), action());
+ return 0;
+ }
+
+ switch (relation) {
+ case Child:
+ if (entry <= childCount()) {
+ *target = new QAccessibleMenu(action()->menu());
+ ret = 0;
+ }
+ break;
+
+ case Ancestor:{
+ QWidget *parent = owner();
+ QAccessibleInterface *ancestor = parent ? QAccessible::queryAccessibleInterface(parent) : 0;
+ if (ancestor) {
+ if (entry == 1) {
+ *target = ancestor;
+ ret = 0;
+ } else {
+ ret = ancestor->navigate(Ancestor, entry - 1, target);
+ delete ancestor;
+ }
+ }
+ break;}
+ case Up:
+ case Down:{
+ QAccessibleInterface *parent = 0;
+ int ent = navigate(Ancestor, 1, &parent);
+ if (ent == 0) {
+ int index = parent->indexOfChild(this);
+ if (index != -1) {
+ index += (relation == Down ? +1 : -1);
+ ret = parent->navigate(Child, index, target);
+ }
+ }
+ delete parent;
+ break;}
+ case Sibling: {
+ QAccessibleInterface *parent = 0;
+ int ent = navigate(Ancestor, 1, &parent);
+ if (ent == 0) {
+ ret = parent->navigate(Child, entry, target);
+ }
+ delete parent;
+ break;}
+ default:
+ break;
+
+ }
+ if (ret == -1)
+ *target = 0;
+ return ret;
+}
+
+QObject *QAccessibleMenuItem::object() const
+{
+ return m_action;
+}
+
+QRect QAccessibleMenuItem::rect (int child ) const
+{
+ QRect rect;
+ if (child == 0) {
+ QWidget *own = owner();
+#ifndef QT_NO_MENUBAR
+ if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
+ rect = menuBar->actionGeometry(m_action);
+ QPoint globalPos = menuBar->mapToGlobal(QPoint(0,0));
+ rect = rect.translated(globalPos);
+ } else
+#endif // QT_NO_MENUBAR
+ if (QMenu *menu = qobject_cast<QMenu*>(own)) {
+ rect = menu->actionGeometry(m_action);
+ QPoint globalPos = menu->mapToGlobal(QPoint(0,0));
+ rect = rect.translated(globalPos);
+ }
+ } else if (child == 1) {
+ QMenu *menu = m_action->menu();
+ if (menu) {
+ rect = menu->rect();
+ QPoint globalPos = menu->mapToGlobal(QPoint(0,0));
+ rect = rect.translated(globalPos);
+ }
+ }
+ return rect;
+}
+
+QAccessible::Relation QAccessibleMenuItem::relationTo ( int child, const QAccessibleInterface * other, int otherChild ) const
+{
+ if (other->object() == owner()) {
+ return Child;
+ }
+ Q_UNUSED(child)
+ Q_UNUSED(other)
+ Q_UNUSED(otherChild)
+ // ###
+ return Unrelated;
+}
+
+QAccessible::Role QAccessibleMenuItem::role(int /*child*/ ) const
+{
+ return m_action->isSeparator() ? Separator :MenuItem;
+}
+
+void QAccessibleMenuItem::setText ( Text /*t*/, int /*child*/, const QString & /*text */)
+{
+
+}
+
+QAccessible::State QAccessibleMenuItem::state(int child ) const
+{
+ QAccessible::State s = Unavailable;
+
+ if (child == 0) {
+ s = Normal;
+ QWidget *own = owner();
+
+ if (own->testAttribute(Qt::WA_WState_Visible) == false || m_action->isVisible() == false) {
+ s |= Invisible;
+ }
+
+ if (QMenu *menu = qobject_cast<QMenu*>(own)) {
+ if (menu->activeAction() == m_action)
+ s |= Focused;
+#ifndef QT_NO_MENUBAR
+ } else if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
+ if (menuBar->activeAction() == m_action)
+ s |= Focused;
+#endif
+ }
+ if (own->style()->styleHint(QStyle::SH_Menu_MouseTracking))
+ s |= HotTracked;
+ if (m_action->isSeparator() || !m_action->isEnabled())
+ s |= Unavailable;
+ if (m_action->isChecked())
+ s |= Checked;
+ } else if (child == 1) {
+ QMenu *menu = m_action->menu();
+ if (menu) {
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(menu);
+ s = iface->state(0);
+ delete iface;
+ }
+ }
+ return s;
+}
+
+QString QAccessibleMenuItem::text ( Text t, int child ) const
+{
+ QString str;
+ switch (t) {
+ case Name:
+ if (child == 0) {
+ str = m_action->text();
+ } else if (child == 1) {
+ QMenu *m = m_action->menu();
+ if (m)
+ str = m->title();
+ }
+ str = qt_accStripAmp(str);
+ break;
+ case Accelerator:
+ if (child == 0) {
+#ifndef QT_NO_SHORTCUT
+ QKeySequence key = m_action->shortcut();
+ if (!key.isEmpty()) {
+ str = key.toString();
+ } else
+#endif
+ {
+ str = qt_accHotKey(m_action->text());
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return str;
+}
+
+int QAccessibleMenuItem::userActionCount ( int /*child*/ ) const
+{
+ return 0;
+}
+
+
+QAction *QAccessibleMenuItem::action() const
+{
+ return m_action;
+}
+
+QWidget *QAccessibleMenuItem::owner() const
+{
+ return m_owner;
+}
+
+#endif // QT_NO_MENU
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ACCESSIBILITY
+
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.h b/src/plugins/accessible/widgets/qaccessiblemenu.h
new file mode 100644
index 0000000000..7decca02c7
--- /dev/null
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLEMENU_H
+#define QACCESSIBLEMENU_H
+
+#include <QtGui/qaccessiblewidget.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+#ifndef QT_NO_MENU
+class QMenu;
+class QMenuBar;
+class QAction;
+
+class QAccessibleMenu : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleMenu(QWidget *w);
+
+ int childCount() const;
+ int childAt(int x, int y) const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+ int indexOfChild( const QAccessibleInterface *child ) const;
+
+ QString actionText(int action, QAccessible::Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+
+protected:
+ QMenu *menu() const;
+};
+
+#ifndef QT_NO_MENUBAR
+class QAccessibleMenuBar : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleMenuBar(QWidget *w);
+
+ int childCount() const;
+ int childAt(int x, int y) const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+ int indexOfChild( const QAccessibleInterface *child ) const;
+
+ QString actionText(int action, QAccessible::Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+
+protected:
+ QMenuBar *menuBar() const;
+};
+#endif // QT_NO_MENUBAR
+
+
+
+class QAccessibleMenuItem : public QAccessibleInterface
+{
+public:
+ explicit QAccessibleMenuItem(QWidget *owner, QAction *w);
+
+ virtual ~QAccessibleMenuItem();
+ virtual QString actionText ( int action, Text t, int child ) const;
+ virtual int childAt ( int x, int y ) const;
+ virtual int childCount () const;
+ virtual bool doAction ( int action, int child, const QVariantList & params = QVariantList() );
+ virtual int indexOfChild ( const QAccessibleInterface * child ) const;
+ virtual bool isValid () const;
+ virtual int navigate ( RelationFlag relation, int entry, QAccessibleInterface ** target ) const;
+ virtual QObject * object () const;
+ virtual QRect rect ( int child ) const;
+ virtual Relation relationTo ( int child, const QAccessibleInterface * other, int otherChild ) const;
+ virtual Role role ( int child ) const;
+ virtual void setText ( Text t, int child, const QString & text );
+ virtual State state ( int child ) const;
+ virtual QString text ( Text t, int child ) const;
+ virtual int userActionCount ( int child ) const;
+
+ QWidget *owner() const;
+
+
+protected:
+ QAction *action() const;
+private:
+ QAction *m_action;
+ QWidget *m_owner; // can hold either QMenu or the QMenuBar that contains the action
+};
+
+#endif // QT_NO_MENU
+
+QT_END_NAMESPACE
+#endif // QT_NO_ACCESSIBILITY
+#endif // QACCESSIBLEMENU_H
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
new file mode 100644
index 0000000000..09b5015785
--- /dev/null
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -0,0 +1,1667 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblewidgets.h"
+#include "qabstracttextdocumentlayout.h"
+#include "qapplication.h"
+#include "qclipboard.h"
+#include "qtextedit.h"
+#include "private/qtextedit_p.h"
+#include "qtextdocument.h"
+#include "qtextobject.h"
+#include "qscrollbar.h"
+#include "qdebug.h"
+#include <QApplication>
+#include <QStackedWidget>
+#include <QToolBox>
+#include <QMdiArea>
+#include <QMdiSubWindow>
+#include <QWorkspace>
+#include <QDialogButtonBox>
+#include <limits.h>
+#include <QRubberBand>
+#include <QTextBrowser>
+#include <QCalendarWidget>
+#include <QAbstractItemView>
+#include <QDockWidget>
+#include <QMainWindow>
+#include <QAbstractButton>
+#include <private/qdockwidget_p.h>
+#include <QtGui/QFocusFrame>
+
+#ifndef QT_NO_ACCESSIBILITY
+
+QT_BEGIN_NAMESPACE
+
+using namespace QAccessible2;
+
+QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
+{
+ if (widget == 0)
+ return QList<QWidget*>();
+ QList<QObject*> list = widget->children();
+ QList<QWidget*> widgets;
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(list.at(i));
+ if (!w)
+ continue;
+ QString objectName = w->objectName();
+ if ((includeTopLevel || !w->isWindow())
+ && !qobject_cast<QFocusFrame*>(w)
+ && !qobject_cast<QMenu*>(w)
+ && objectName != QLatin1String("qt_rubberband")
+ && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) {
+ widgets.append(w);
+ }
+ }
+ return widgets;
+}
+
+static inline int distance(QWidget *source, QWidget *target,
+ QAccessible::RelationFlag relation)
+{
+ if (!source || !target)
+ return -1;
+
+ int returnValue = -1;
+ switch (relation) {
+ case QAccessible::Up:
+ if (target->y() <= source->y())
+ returnValue = source->y() - target->y();
+ break;
+ case QAccessible::Down:
+ if (target->y() >= source->y() + source->height())
+ returnValue = target->y() - (source->y() + source->height());
+ break;
+ case QAccessible::Right:
+ if (target->x() >= source->x() + source->width())
+ returnValue = target->x() - (source->x() + source->width());
+ break;
+ case QAccessible::Left:
+ if (target->x() <= source->x())
+ returnValue = source->x() - target->x();
+ break;
+ default:
+ break;
+ }
+ return returnValue;
+}
+
+static inline QWidget *mdiAreaNavigate(QWidget *area,
+ QAccessible::RelationFlag relation, int entry)
+{
+#if defined(QT_NO_MDIAREA) && defined(QT_NO_WORKSPACE)
+ Q_UNUSED(area);
+#endif
+#ifndef QT_NO_MDIAREA
+ const QMdiArea *mdiArea = qobject_cast<QMdiArea *>(area);
+#endif
+#ifndef QT_NO_WORKSPACE
+ const QWorkspace *workspace = qobject_cast<QWorkspace *>(area);
+#endif
+ if (true
+#ifndef QT_NO_MDIAREA
+ && !mdiArea
+#endif
+#ifndef QT_NO_WORKSPACE
+ && !workspace
+#endif
+ )
+ return 0;
+
+ QWidgetList windows;
+#ifndef QT_NO_MDIAREA
+ if (mdiArea) {
+ foreach (QMdiSubWindow *window, mdiArea->subWindowList())
+ windows.append(window);
+ } else
+#endif
+ {
+#ifndef QT_NO_WORKSPACE
+ foreach (QWidget *window, workspace->windowList())
+ windows.append(window->parentWidget());
+#endif
+ }
+
+ if (windows.isEmpty() || entry < 1 || entry > windows.count())
+ return 0;
+
+ QWidget *source = windows.at(entry - 1);
+ QMap<int, QWidget *> candidates;
+ foreach (QWidget *window, windows) {
+ if (source == window)
+ continue;
+ int candidateDistance = distance(source, window, relation);
+ if (candidateDistance >= 0)
+ candidates.insert(candidateDistance, window);
+ }
+
+ int minimumDistance = INT_MAX;
+ QWidget *target = 0;
+ foreach (QWidget *candidate, candidates) {
+ switch (relation) {
+ case QAccessible::Up:
+ case QAccessible::Down:
+ if (qAbs(candidate->x() - source->x()) < minimumDistance) {
+ target = candidate;
+ minimumDistance = qAbs(candidate->x() - source->x());
+ }
+ break;
+ case QAccessible::Left:
+ case QAccessible::Right:
+ if (qAbs(candidate->y() - source->y()) < minimumDistance) {
+ target = candidate;
+ minimumDistance = qAbs(candidate->y() - source->y());
+ }
+ break;
+ default:
+ break;
+ }
+ if (minimumDistance == 0)
+ break;
+ }
+
+#ifndef QT_NO_WORKSPACE
+ if (workspace) {
+ foreach (QWidget *widget, workspace->windowList()) {
+ if (widget->parentWidget() == target)
+ target = widget;
+ }
+ }
+#endif
+ return target;
+}
+
+#ifndef QT_NO_TEXTEDIT
+
+/*!
+ \class QAccessibleTextEdit
+ \brief The QAccessibleTextEdit class implements the QAccessibleInterface for richtext editors.
+ \internal
+*/
+
+static QTextBlock qTextBlockAt(const QTextDocument *doc, int pos)
+{
+ Q_ASSERT(pos >= 0);
+
+ QTextBlock block = doc->begin();
+ int i = 0;
+ while (block.isValid() && i < pos) {
+ block = block.next();
+ ++i;
+ }
+ return block;
+}
+
+static int qTextBlockPosition(QTextBlock block)
+{
+ int child = 0;
+ while (block.isValid()) {
+ block = block.previous();
+ ++child;
+ }
+
+ return child;
+}
+
+/*!
+ \fn QAccessibleTextEdit::QAccessibleTextEdit(QWidget* widget)
+
+ Constructs a QAccessibleTextEdit object for a \a widget.
+*/
+QAccessibleTextEdit::QAccessibleTextEdit(QWidget *o)
+: QAccessibleWidgetEx(o, EditableText)
+{
+ Q_ASSERT(widget()->inherits("QTextEdit"));
+ childOffset = QAccessibleWidgetEx::childCount();
+}
+
+/*! Returns the text edit. */
+QTextEdit *QAccessibleTextEdit::textEdit() const
+{
+ return static_cast<QTextEdit *>(widget());
+}
+
+QRect QAccessibleTextEdit::rect(int child) const
+{
+ if (child <= childOffset)
+ return QAccessibleWidgetEx::rect(child);
+
+ QTextEdit *edit = textEdit();
+ QTextBlock block = qTextBlockAt(edit->document(), child - childOffset - 1);
+ if (!block.isValid())
+ return QRect();
+
+ QRect rect = edit->document()->documentLayout()->blockBoundingRect(block).toRect();
+ rect.translate(-edit->horizontalScrollBar()->value(), -edit->verticalScrollBar()->value());
+
+ rect = edit->viewport()->rect().intersect(rect);
+ if (rect.isEmpty())
+ return QRect();
+
+ return rect.translated(edit->viewport()->mapToGlobal(QPoint(0, 0)));
+}
+
+int QAccessibleTextEdit::childAt(int x, int y) const
+{
+ QTextEdit *edit = textEdit();
+ if (!edit->isVisible())
+ return -1;
+
+ QPoint point = edit->viewport()->mapFromGlobal(QPoint(x, y));
+ QTextBlock block = edit->cursorForPosition(point).block();
+ if (block.isValid())
+ return qTextBlockPosition(block) + childOffset;
+
+ return QAccessibleWidgetEx::childAt(x, y);
+}
+
+/*! \reimp */
+QString QAccessibleTextEdit::text(Text t, int child) const
+{
+ if (t == Value) {
+ if (child > childOffset)
+ return qTextBlockAt(textEdit()->document(), child - childOffset - 1).text();
+ if (!child)
+ return textEdit()->toPlainText();
+ }
+
+ return QAccessibleWidgetEx::text(t, child);
+}
+
+/*! \reimp */
+void QAccessibleTextEdit::setText(Text t, int child, const QString &text)
+{
+ if (t != Value || (child > 0 && child <= childOffset)) {
+ QAccessibleWidgetEx::setText(t, child, text);
+ return;
+ }
+ if (textEdit()->isReadOnly())
+ return;
+
+ if (!child) {
+ textEdit()->setText(text);
+ return;
+ }
+ QTextBlock block = qTextBlockAt(textEdit()->document(), child - childOffset - 1);
+ if (!block.isValid())
+ return;
+
+ QTextCursor cursor(block);
+ cursor.select(QTextCursor::BlockUnderCursor);
+ cursor.insertText(text);
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleTextEdit::role(int child) const
+{
+ if (child > childOffset)
+ return EditableText;
+ return QAccessibleWidgetEx::role(child);
+}
+
+QVariant QAccessibleTextEdit::invokeMethodEx(QAccessible::Method method, int child,
+ const QVariantList &params)
+{
+ if (child)
+ return QVariant();
+
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods << SetCursorPosition << GetCursorPosition;
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
+ }
+ case SetCursorPosition:
+ setCursorPosition(params.value(0).toInt());
+ return true;
+ case GetCursorPosition:
+ return textEdit()->textCursor().position();
+ default:
+ return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
+ }
+}
+
+int QAccessibleTextEdit::childCount() const
+{
+ return childOffset + textEdit()->document()->blockCount();
+}
+#endif // QT_NO_TEXTEDIT
+
+#ifndef QT_NO_STACKEDWIDGET
+// ======================= QAccessibleStackedWidget ======================
+QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget)
+ : QAccessibleWidgetEx(widget, LayeredPane)
+{
+ Q_ASSERT(qobject_cast<QStackedWidget *>(widget));
+}
+
+QVariant QAccessibleStackedWidget::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+
+int QAccessibleStackedWidget::childAt(int x, int y) const
+{
+ if (!stackedWidget()->isVisible())
+ return -1;
+ QWidget *currentWidget = stackedWidget()->currentWidget();
+ if (!currentWidget)
+ return -1;
+ QPoint position = currentWidget->mapFromGlobal(QPoint(x, y));
+ if (currentWidget->rect().contains(position))
+ return 1;
+ return -1;
+}
+
+int QAccessibleStackedWidget::childCount() const
+{
+ return stackedWidget()->count();
+}
+
+int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (!child || (stackedWidget()->currentWidget() != child->object()))
+ return -1;
+ return 1;
+}
+
+int QAccessibleStackedWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+
+ QObject *targetObject = 0;
+ switch (relation) {
+ case Child:
+ if (entry != 1)
+ return -1;
+ targetObject = stackedWidget()->currentWidget();
+ break;
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ return *target ? 0 : -1;
+}
+
+QStackedWidget *QAccessibleStackedWidget::stackedWidget() const
+{
+ return static_cast<QStackedWidget *>(object());
+}
+#endif // QT_NO_STACKEDWIDGET
+
+#ifndef QT_NO_TOOLBOX
+// ======================= QAccessibleToolBox ======================
+QAccessibleToolBox::QAccessibleToolBox(QWidget *widget)
+ : QAccessibleWidgetEx(widget, LayeredPane)
+{
+ Q_ASSERT(qobject_cast<QToolBox *>(widget));
+}
+
+QString QAccessibleToolBox::text(Text textType, int child) const
+{
+ if (textType != Value || child <= 0 || child > toolBox()->count())
+ return QAccessibleWidgetEx::text(textType, child);
+ return toolBox()->itemText(child - 1);
+}
+
+void QAccessibleToolBox::setText(Text textType, int child, const QString &text)
+{
+ if (textType != Value || child <= 0 || child > toolBox()->count()) {
+ QAccessibleWidgetEx::setText(textType, child, text);
+ return;
+ }
+ toolBox()->setItemText(child - 1, text);
+}
+
+QAccessible::State QAccessibleToolBox::state(int child) const
+{
+ QWidget *childWidget = toolBox()->widget(child - 1);
+ if (!childWidget)
+ return QAccessibleWidgetEx::state(child);
+ QAccessible::State childState = QAccessible::Normal;
+ if (toolBox()->currentWidget() == childWidget)
+ childState |= QAccessible::Expanded;
+ else
+ childState |= QAccessible::Collapsed;
+ return childState;
+}
+
+QVariant QAccessibleToolBox::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+int QAccessibleToolBox::childCount() const
+{
+ return toolBox()->count();
+}
+
+int QAccessibleToolBox::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (!child)
+ return -1;
+ QWidget *childWidget = qobject_cast<QWidget *>(child->object());
+ if (!childWidget)
+ return -1;
+ int index = toolBox()->indexOf(childWidget);
+ if (index != -1)
+ ++index;
+ return index;
+}
+
+int QAccessibleToolBox::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ if (entry <= 0 || entry > toolBox()->count())
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ int index = -1;
+ if (relation == QAccessible::Up)
+ index = entry - 2;
+ else if (relation == QAccessible::Down)
+ index = entry;
+ *target = QAccessible::queryAccessibleInterface(toolBox()->widget(index));
+ return *target ? 0: -1;
+}
+
+QToolBox * QAccessibleToolBox::toolBox() const
+{
+ return static_cast<QToolBox *>(object());
+}
+#endif // QT_NO_TOOLBOX
+
+// ======================= QAccessibleMdiArea ======================
+#ifndef QT_NO_MDIAREA
+QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget)
+ : QAccessibleWidgetEx(widget, LayeredPane)
+{
+ Q_ASSERT(qobject_cast<QMdiArea *>(widget));
+}
+
+QAccessible::State QAccessibleMdiArea::state(int child) const
+{
+ if (child < 0)
+ return QAccessibleWidgetEx::state(child);
+ if (child == 0)
+ return QAccessible::Normal;
+ QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
+ if (subWindows.isEmpty() || child > subWindows.count())
+ return QAccessibleWidgetEx::state(child);
+ if (subWindows.at(child - 1) == mdiArea()->activeSubWindow())
+ return QAccessible::Focused;
+ return QAccessible::Normal;
+}
+
+QVariant QAccessibleMdiArea::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+int QAccessibleMdiArea::childCount() const
+{
+ return mdiArea()->subWindowList().count();
+}
+
+int QAccessibleMdiArea::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (!child || !child->object() || mdiArea()->subWindowList().isEmpty())
+ return -1;
+ if (QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(child->object())) {
+ int index = mdiArea()->subWindowList().indexOf(window);
+ if (index != -1)
+ return ++index;
+ }
+ return -1;
+}
+
+int QAccessibleMdiArea::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ QWidget *targetObject = 0;
+ QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
+ switch (relation) {
+ case Child:
+ if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
+ return -1;
+ targetObject = subWindows.at(entry - 1);
+ break;
+ case Up:
+ case Down:
+ case Left:
+ case Right:
+ targetObject = mdiAreaNavigate(mdiArea(), relation, entry);
+ break;
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ return *target ? 0: -1;
+}
+
+QMdiArea *QAccessibleMdiArea::mdiArea() const
+{
+ return static_cast<QMdiArea *>(object());
+}
+
+// ======================= QAccessibleMdiSubWindow ======================
+QAccessibleMdiSubWindow::QAccessibleMdiSubWindow(QWidget *widget)
+ : QAccessibleWidgetEx(widget, QAccessible::Window)
+{
+ Q_ASSERT(qobject_cast<QMdiSubWindow *>(widget));
+}
+
+QString QAccessibleMdiSubWindow::text(Text textType, int child) const
+{
+ if (textType == QAccessible::Name && (child == 0 || child == 1)) {
+ QString title = mdiSubWindow()->windowTitle();
+ title.replace(QLatin1String("[*]"), QLatin1String(""));
+ return title;
+ }
+ return QAccessibleWidgetEx::text(textType, child);
+}
+
+void QAccessibleMdiSubWindow::setText(Text textType, int child, const QString &text)
+{
+ if (textType == QAccessible::Name && (child == 0 || child == 1))
+ mdiSubWindow()->setWindowTitle(text);
+ else
+ QAccessibleWidgetEx::setText(textType, child, text);
+}
+
+QAccessible::State QAccessibleMdiSubWindow::state(int child) const
+{
+ if (child != 0 || !mdiSubWindow()->parent())
+ return QAccessibleWidgetEx::state(child);
+ QAccessible::State state = QAccessible::Normal | QAccessible::Focusable;
+ if (!mdiSubWindow()->isMaximized())
+ state |= (QAccessible::Movable | QAccessible::Sizeable);
+ if (mdiSubWindow()->isAncestorOf(QApplication::focusWidget())
+ || QApplication::focusWidget() == mdiSubWindow())
+ state |= QAccessible::Focused;
+ if (!mdiSubWindow()->isVisible())
+ state |= QAccessible::Invisible;
+ if (!mdiSubWindow()->parentWidget()->contentsRect().contains(mdiSubWindow()->geometry()))
+ state |= QAccessible::Offscreen;
+ if (!mdiSubWindow()->isEnabled())
+ state |= QAccessible::Unavailable;
+ return state;
+}
+
+QVariant QAccessibleMdiSubWindow::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+int QAccessibleMdiSubWindow::childCount() const
+{
+ if (mdiSubWindow()->widget())
+ return 1;
+ return 0;
+}
+
+int QAccessibleMdiSubWindow::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (child && child->object() && child->object() == mdiSubWindow()->widget())
+ return 1;
+ return -1;
+}
+
+int QAccessibleMdiSubWindow::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+
+ if (!mdiSubWindow()->parent())
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+
+ QWidget *targetObject = 0;
+ QMdiSubWindow *source = mdiSubWindow();
+ switch (relation) {
+ case Child:
+ if (entry != 1 || !source->widget())
+ return -1;
+ targetObject = source->widget();
+ break;
+ case Up:
+ case Down:
+ case Left:
+ case Right: {
+ if (entry != 0)
+ break;
+ QWidget *parent = source->parentWidget();
+ while (parent && !parent->inherits("QMdiArea"))
+ parent = parent->parentWidget();
+ QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parent);
+ if (!mdiArea)
+ break;
+ int index = mdiArea->subWindowList().indexOf(source);
+ if (index == -1)
+ break;
+ if (QWidget *dest = mdiAreaNavigate(mdiArea, relation, index + 1)) {
+ *target = QAccessible::queryAccessibleInterface(dest);
+ return *target ? 0 : -1;
+ }
+ break;
+ }
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ return *target ? 0: -1;
+}
+
+QRect QAccessibleMdiSubWindow::rect(int child) const
+{
+ if (mdiSubWindow()->isHidden())
+ return QRect();
+ if (!mdiSubWindow()->parent())
+ return QAccessibleWidgetEx::rect(child);
+ const QPoint pos = mdiSubWindow()->mapToGlobal(QPoint(0, 0));
+ if (child == 0)
+ return QRect(pos, mdiSubWindow()->size());
+ if (child == 1 && mdiSubWindow()->widget()) {
+ if (mdiSubWindow()->widget()->isHidden())
+ return QRect();
+ const QRect contentsRect = mdiSubWindow()->contentsRect();
+ return QRect(pos.x() + contentsRect.x(), pos.y() + contentsRect.y(),
+ contentsRect.width(), contentsRect.height());
+ }
+ return QRect();
+}
+
+int QAccessibleMdiSubWindow::childAt(int x, int y) const
+{
+ if (!mdiSubWindow()->isVisible())
+ return -1;
+ if (!mdiSubWindow()->parent())
+ return QAccessibleWidgetEx::childAt(x, y);
+ const QRect globalGeometry = rect(0);
+ if (!globalGeometry.isValid())
+ return -1;
+ const QRect globalChildGeometry = rect(1);
+ if (globalChildGeometry.isValid() && globalChildGeometry.contains(QPoint(x, y)))
+ return 1;
+ if (globalGeometry.contains(QPoint(x, y)))
+ return 0;
+ return -1;
+}
+
+QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const
+{
+ return static_cast<QMdiSubWindow *>(object());
+}
+#endif // QT_NO_MDIAREA
+
+// ======================= QAccessibleWorkspace ======================
+#ifndef QT_NO_WORKSPACE
+QAccessibleWorkspace::QAccessibleWorkspace(QWidget *widget)
+ : QAccessibleWidgetEx(widget, LayeredPane)
+{
+ Q_ASSERT(qobject_cast<QWorkspace *>(widget));
+}
+
+QAccessible::State QAccessibleWorkspace::state(int child) const
+{
+ if (child < 0)
+ return QAccessibleWidgetEx::state(child);
+ if (child == 0)
+ return QAccessible::Normal;
+ QWidgetList subWindows = workspace()->windowList();
+ if (subWindows.isEmpty() || child > subWindows.count())
+ return QAccessibleWidgetEx::state(child);
+ if (subWindows.at(child - 1) == workspace()->activeWindow())
+ return QAccessible::Focused;
+ return QAccessible::Normal;
+}
+
+QVariant QAccessibleWorkspace::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+int QAccessibleWorkspace::childCount() const
+{
+ return workspace()->windowList().count();
+}
+
+int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (!child || !child->object() || workspace()->windowList().isEmpty())
+ return -1;
+ if (QWidget *window = qobject_cast<QWidget *>(child->object())) {
+ int index = workspace()->windowList().indexOf(window);
+ if (index != -1)
+ return ++index;
+ }
+ return -1;
+}
+
+int QAccessibleWorkspace::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ QWidget *targetObject = 0;
+ QWidgetList subWindows = workspace()->windowList();
+ switch (relation) {
+ case Child:
+ if (entry < 1 || subWindows.isEmpty() || entry > subWindows.count())
+ return -1;
+ targetObject = subWindows.at(entry - 1);
+ break;
+ case Up:
+ case Down:
+ case Left:
+ case Right:
+ targetObject = mdiAreaNavigate(workspace(), relation, entry);
+ break;
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ return *target ? 0: -1;
+}
+
+QWorkspace *QAccessibleWorkspace::workspace() const
+{
+ return static_cast<QWorkspace *>(object());
+}
+#endif
+
+#ifndef QT_NO_DIALOGBUTTONBOX
+// ======================= QAccessibleDialogButtonBox ======================
+QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(QWidget *widget)
+ : QAccessibleWidgetEx(widget, Grouping)
+{
+ Q_ASSERT(qobject_cast<QDialogButtonBox*>(widget));
+}
+
+QVariant QAccessibleDialogButtonBox::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+#endif // QT_NO_DIALOGBUTTONBOX
+
+#ifndef QT_NO_TEXTBROWSER
+QAccessibleTextBrowser::QAccessibleTextBrowser(QWidget *widget)
+ : QAccessibleTextEdit(widget)
+{
+ Q_ASSERT(qobject_cast<QTextBrowser *>(widget));
+}
+
+QAccessible::Role QAccessibleTextBrowser::role(int child) const
+{
+ if (child != 0)
+ return QAccessibleTextEdit::role(child);
+ return QAccessible::StaticText;
+}
+#endif // QT_NO_TEXTBROWSER
+
+#ifndef QT_NO_CALENDARWIDGET
+// ===================== QAccessibleCalendarWidget ========================
+QAccessibleCalendarWidget::QAccessibleCalendarWidget(QWidget *widget)
+ : QAccessibleWidgetEx(widget, Table)
+{
+ Q_ASSERT(qobject_cast<QCalendarWidget *>(widget));
+}
+
+QVariant QAccessibleCalendarWidget::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+int QAccessibleCalendarWidget::childCount() const
+{
+ return calendarWidget()->isNavigationBarVisible() ? 2 : 1;
+}
+
+int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (!child || !child->object() || childCount() <= 0)
+ return -1;
+ if (qobject_cast<QAbstractItemView *>(child->object()))
+ return childCount();
+ return 1;
+}
+
+int QAccessibleCalendarWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ if (entry <= 0 || entry > childCount())
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ QWidget *targetWidget = 0;
+ switch (relation) {
+ case Child:
+ if (childCount() == 1) {
+ targetWidget = calendarView();
+ } else {
+ if (entry == 1)
+ targetWidget = navigationBar();
+ else
+ targetWidget = calendarView();
+ }
+ break;
+ case Up:
+ if (entry == 2)
+ targetWidget = navigationBar();
+ break;
+ case Down:
+ if (entry == 1 && childCount() == 2)
+ targetWidget = calendarView();
+ break;
+ default:
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+ }
+ *target = queryAccessibleInterface(targetWidget);
+ return *target ? 0: -1;
+}
+
+QRect QAccessibleCalendarWidget::rect(int child) const
+{
+ if (!calendarWidget()->isVisible() || child > childCount())
+ return QRect();
+ if (child == 0)
+ return QAccessibleWidgetEx::rect(child);
+ QWidget *childWidget = 0;
+ if (childCount() == 2)
+ childWidget = child == 1 ? navigationBar() : calendarView();
+ else
+ childWidget = calendarView();
+ return QRect(childWidget->mapToGlobal(QPoint(0, 0)), childWidget->size());
+}
+
+int QAccessibleCalendarWidget::childAt(int x, int y) const
+{
+ const QPoint globalTargetPos = QPoint(x, y);
+ if (!rect(0).contains(globalTargetPos))
+ return -1;
+ if (rect(1).contains(globalTargetPos))
+ return 1;
+ if (rect(2).contains(globalTargetPos))
+ return 2;
+ return 0;
+}
+
+QCalendarWidget *QAccessibleCalendarWidget::calendarWidget() const
+{
+ return static_cast<QCalendarWidget *>(object());
+}
+
+QAbstractItemView *QAccessibleCalendarWidget::calendarView() const
+{
+ foreach (QObject *child, calendarWidget()->children()) {
+ if (child->objectName() == QLatin1String("qt_calendar_calendarview"))
+ return static_cast<QAbstractItemView *>(child);
+ }
+ return 0;
+}
+
+QWidget *QAccessibleCalendarWidget::navigationBar() const
+{
+ foreach (QObject *child, calendarWidget()->children()) {
+ if (child->objectName() == QLatin1String("qt_calendar_navigationbar"))
+ return static_cast<QWidget *>(child);
+ }
+ return 0;
+}
+#endif // QT_NO_CALENDARWIDGET
+
+#ifndef QT_NO_DOCKWIDGET
+QAccessibleDockWidget::QAccessibleDockWidget(QWidget *widget)
+ : QAccessibleWidgetEx(widget, Window)
+{
+
+}
+
+int QAccessibleDockWidget::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
+{
+ if (relation == Child) {
+ if (entry == 1) {
+ *iface = new QAccessibleTitleBar(dockWidget());
+ return 0;
+ } else if (entry == 2) {
+ if (dockWidget()->widget())
+ *iface = QAccessible::queryAccessibleInterface(dockWidget()->widget());
+ return 0;
+ }
+ *iface = 0;
+ return -1;
+ }
+ return QAccessibleWidgetEx::navigate(relation, entry, iface);
+}
+
+int QAccessibleDockWidget::childAt(int x, int y) const
+{
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(x,y))
+ return i;
+ }
+ return -1;
+}
+
+int QAccessibleDockWidget::childCount() const
+{
+ return dockWidget()->widget() ? 2 : 1;
+}
+
+int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const
+{
+ if (child) {
+ if (child->role(0) == TitleBar) {
+ return 1;
+ } else {
+ return 2; //###
+ }
+ }
+ return -1;
+}
+
+QAccessible::Role QAccessibleDockWidget::role(int child) const
+{
+ switch (child) {
+ case 0:
+ return Window;
+ case 1:
+ return TitleBar;
+ case 2:
+ //###
+ break;
+ default:
+ break;
+ }
+ return NoRole;
+}
+
+QAccessible::State QAccessibleDockWidget::state(int child) const
+{
+ //### mark tabified widgets as invisible
+ return QAccessibleWidgetEx::state(child);
+}
+
+QRect QAccessibleDockWidget::rect (int child ) const
+{
+ QRect rect;
+ bool mapToGlobal = true;
+ if (child == 0) {
+ if (dockWidget()->isFloating()) {
+ rect = dockWidget()->frameGeometry();
+ mapToGlobal = false;
+ } else {
+ rect = dockWidget()->rect();
+ }
+ }else if (child == 1) {
+ QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(dockWidget()->layout());
+ rect = layout->titleArea();
+ }else if (child == 2) {
+ if (dockWidget()->widget())
+ rect = dockWidget()->widget()->geometry();
+ }
+ if (rect.isNull())
+ return rect;
+
+ if (mapToGlobal)
+ rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft()));
+
+ return rect;
+}
+
+QVariant QAccessibleDockWidget::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+QDockWidget *QAccessibleDockWidget::dockWidget() const
+{
+ return static_cast<QDockWidget *>(object());
+}
+
+////
+// QAccessibleTitleBar
+////
+QAccessibleTitleBar::QAccessibleTitleBar(QDockWidget *widget)
+ : m_dockWidget(widget)
+{
+
+}
+
+int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
+{
+ if (entry == 0 || relation == Self) {
+ *iface = new QAccessibleTitleBar(dockWidget());
+ return 0;
+ }
+ switch (relation) {
+ case Child:
+ case FocusChild:
+ if (entry >= 1) {
+ QDockWidgetLayout *layout = dockWidgetLayout();
+ int index = 1;
+ int role;
+ for (role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) {
+ QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role);
+ if (!w->isVisible())
+ continue;
+ if (index == entry)
+ break;
+ ++index;
+ }
+ *iface = 0;
+ return role > QDockWidgetLayout::FloatButton ? -1 : index;
+ }
+ break;
+ case Ancestor:
+ {
+ QAccessibleDockWidget *target = new QAccessibleDockWidget(dockWidget());
+ int index;
+ if (entry == 1) {
+ *iface = target;
+ return 0;
+ }
+ index = target->navigate(Ancestor, entry - 1, iface);
+ delete target;
+ return index;
+
+ break;}
+ case Sibling:
+ return navigate(Child, entry, iface);
+ break;
+ default:
+ break;
+ }
+ *iface = 0;
+ return -1;
+}
+
+QAccessible::Relation QAccessibleTitleBar::relationTo(int /*child*/, const QAccessibleInterface * /*other*/, int /*otherChild*/) const
+{
+ return Unrelated; //###
+}
+
+int QAccessibleTitleBar::indexOfChild(const QAccessibleInterface * /*child*/) const
+{
+ return -1;
+}
+
+int QAccessibleTitleBar::childCount() const
+{
+ QDockWidgetLayout *layout = dockWidgetLayout();
+ int count = 0;
+ for (int role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) {
+ QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role);
+ if (w && w->isVisible())
+ ++count;
+ }
+ return count;
+}
+
+QString QAccessibleTitleBar::text(Text t, int child) const
+{
+ if (!child) {
+ if (t == Value) {
+ return dockWidget()->windowTitle();
+ }
+ }
+ return QString();
+}
+
+QAccessible::State QAccessibleTitleBar::state(int child) const
+{
+ QAccessible::State state = Normal;
+ if (child) {
+ QDockWidgetLayout *layout = dockWidgetLayout();
+ QAbstractButton *b = static_cast<QAbstractButton *>(layout->widgetForRole((QDockWidgetLayout::Role)child));
+ if (b) {
+ if (b->isDown())
+ state |= Pressed;
+ }
+ } else {
+ QDockWidget *w = dockWidget();
+ if (w->testAttribute(Qt::WA_WState_Visible) == false)
+ state |= Invisible;
+ if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow())
+ state |= Focusable;
+ if (w->hasFocus())
+ state |= Focused;
+ if (!w->isEnabled())
+ state |= Unavailable;
+ }
+
+ return state;
+}
+
+QRect QAccessibleTitleBar::rect (int child ) const
+{
+ bool mapToGlobal = true;
+ QRect rect;
+ if (child == 0) {
+ if (dockWidget()->isFloating()) {
+ rect = dockWidget()->frameGeometry();
+ QPoint globalPos = dockWidget()->mapToGlobal( dockWidget()->widget()->rect().topLeft() );
+ globalPos.ry()--;
+ rect.setBottom(globalPos.y());
+ mapToGlobal = false;
+ } else {
+ QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(dockWidget()->layout());
+ rect = layout->titleArea();
+ }
+ }else if (child >= 1 && child <= childCount()) {
+ QDockWidgetLayout *layout = dockWidgetLayout();
+ int index = 1;
+ for (int role = QDockWidgetLayout::CloseButton; role <= QDockWidgetLayout::FloatButton; ++role) {
+ QWidget *w = layout->widgetForRole((QDockWidgetLayout::Role)role);
+ if (!w || !w->isVisible())
+ continue;
+ if (index == child) {
+ rect = w->geometry();
+ break;
+ }
+ ++index;
+ }
+ }
+ if (rect.isNull())
+ return rect;
+
+ if (mapToGlobal)
+ rect.moveTopLeft(dockWidget()->mapToGlobal(rect.topLeft()));
+ return rect;
+}
+
+int QAccessibleTitleBar::childAt(int x, int y) const
+{
+ for (int i = childCount(); i >= 0; --i) {
+ if (rect(i).contains(x,y))
+ return i;
+ }
+ return -1;
+}
+
+QObject *QAccessibleTitleBar::object() const
+{
+ return 0;
+}
+
+QDockWidgetLayout *QAccessibleTitleBar::dockWidgetLayout() const
+{
+ return qobject_cast<QDockWidgetLayout*>(dockWidget()->layout());
+}
+
+QDockWidget *QAccessibleTitleBar::dockWidget() const
+{
+ return m_dockWidget;
+}
+
+QString QAccessibleTitleBar::actionText(int action, Text t, int child) const
+{
+ QString str;
+ if (child >= 1 && child <= childCount()) {
+ if (t == Name) {
+ switch (action) {
+ case Press:
+ case DefaultAction:
+ if (child == QDockWidgetLayout::CloseButton) {
+ str = QDockWidget::tr("Close");
+ } else if (child == QDockWidgetLayout::FloatButton) {
+ str = dockWidget()->isFloating() ? QDockWidget::tr("Dock")
+ : QDockWidget::tr("Float");
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return str;
+}
+
+bool QAccessibleTitleBar::doAction(int action, int child, const QVariantList& /*params*/)
+{
+ if (!child || !dockWidget()->isEnabled())
+ return false;
+
+ switch (action) {
+ case DefaultAction:
+ case Press: {
+ QDockWidgetLayout *layout = dockWidgetLayout();
+ QAbstractButton *btn = static_cast<QAbstractButton *>(layout->widgetForRole((QDockWidgetLayout::Role)child));
+ if (btn)
+ btn->animateClick();
+ return true;
+ break;}
+ default:
+ break;
+ }
+
+ return false;
+}
+
+int QAccessibleTitleBar::userActionCount (int /*child*/) const
+{
+ return 0;
+}
+
+QAccessible::Role QAccessibleTitleBar::role(int child) const
+{
+ switch (child) {
+ case 0:
+ return TitleBar;
+ break;
+ default:
+ if (child >= 1 && child <= childCount())
+ return PushButton;
+ break;
+ }
+
+ return NoRole;
+}
+
+void QAccessibleTitleBar::setText(Text /*t*/, int /*child*/, const QString &/*text*/)
+{
+
+}
+
+bool QAccessibleTitleBar::isValid() const
+{
+ return dockWidget();
+}
+
+#endif // QT_NO_DOCKWIDGET
+
+#ifndef QT_NO_TEXTEDIT
+void QAccessibleTextEdit::addSelection(int startOffset, int endOffset)
+{
+ setSelection(0, startOffset, endOffset);
+}
+
+QString QAccessibleTextEdit::attributes(int offset, int *startOffset, int *endOffset)
+{
+ // TODO - wait for a definition of attributes
+ Q_UNUSED(offset);
+ Q_UNUSED(startOffset);
+ Q_UNUSED(endOffset);
+ return QString();
+}
+
+int QAccessibleTextEdit::cursorPosition()
+{
+ return textEdit()->textCursor().position();
+}
+
+QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType)
+{
+ QTextEdit *edit = textEdit();
+ QTextCursor cursor(edit->document());
+ cursor.setPosition(offset);
+
+ if (cursor.position() != offset)
+ return QRect();
+
+ QRect r = edit->cursorRect(cursor);
+ if (cursor.movePosition(QTextCursor::NextCharacter)) {
+ r.setWidth(edit->cursorRect(cursor).y() - r.y());
+ } else {
+ // we don't know the width of the character - maybe because we're at document end
+ // in that case, IAccessible2 tells us to return the width of a default character
+ int averageCharWidth = QFontMetrics(cursor.charFormat().font()).averageCharWidth();
+ if (edit->layoutDirection() == Qt::RightToLeft)
+ averageCharWidth *= -1;
+ r.setWidth(averageCharWidth);
+ }
+
+ switch (coordType) {
+ case RelativeToScreen:
+ r.moveTo(edit->viewport()->mapToGlobal(r.topLeft()));
+ break;
+ case RelativeToParent:
+ break;
+ }
+
+ return r;
+}
+
+int QAccessibleTextEdit::selectionCount()
+{
+ return textEdit()->textCursor().hasSelection() ? 1 : 0;
+}
+
+int QAccessibleTextEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType)
+{
+ QTextEdit *edit = textEdit();
+
+ QPoint p = point;
+ if (coordType == RelativeToScreen)
+ p = edit->viewport()->mapFromGlobal(p);
+ // convert to document coordinates
+ p += QPoint(edit->horizontalScrollBar()->value(), edit->verticalScrollBar()->value());
+
+ return edit->document()->documentLayout()->hitTest(p, Qt::ExactHit);
+}
+
+void QAccessibleTextEdit::selection(int selectionIndex, int *startOffset, int *endOffset)
+{
+ *startOffset = *endOffset = 0;
+ QTextCursor cursor = textEdit()->textCursor();
+
+ if (selectionIndex != 0 || !cursor.hasSelection())
+ return;
+
+ *startOffset = cursor.selectionStart();
+ *endOffset = cursor.selectionEnd();
+}
+
+QString QAccessibleTextEdit::text(int startOffset, int endOffset)
+{
+ QTextCursor cursor(textEdit()->document());
+
+ cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
+ cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
+
+ return cursor.selectedText();
+}
+
+QString QAccessibleTextEdit::textBeforeOffset (int offset, BoundaryType boundaryType,
+ int *startOffset, int *endOffset)
+{
+ // TODO - what exactly is before?
+ Q_UNUSED(offset);
+ Q_UNUSED(boundaryType);
+ Q_UNUSED(startOffset);
+ Q_UNUSED(endOffset);
+ return QString();
+}
+
+QString QAccessibleTextEdit::textAfterOffset(int offset, BoundaryType boundaryType,
+ int *startOffset, int *endOffset)
+{
+ // TODO - what exactly is after?
+ Q_UNUSED(offset);
+ Q_UNUSED(boundaryType);
+ Q_UNUSED(startOffset);
+ Q_UNUSED(endOffset);
+ return QString();
+}
+
+QString QAccessibleTextEdit::textAtOffset(int offset, BoundaryType boundaryType,
+ int *startOffset, int *endOffset)
+{
+ Q_ASSERT(startOffset);
+ Q_ASSERT(endOffset);
+
+ *startOffset = *endOffset = -1;
+ QTextEdit *edit = textEdit();
+
+ QTextCursor cursor(edit->document());
+ if (offset >= characterCount())
+ return QString();
+
+ switch (boundaryType) {
+ case CharBoundary:
+ cursor.setPosition(offset);
+ *startOffset = cursor.position();
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ *endOffset = cursor.position();
+ break;
+ case WordBoundary:
+ cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
+ *startOffset = cursor.position();
+ cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+ *endOffset = cursor.position();
+ break;
+ case SentenceBoundary:
+ // TODO - what's a sentence?
+ return QString();
+ case LineBoundary:
+ cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor);
+ *startOffset = cursor.position();
+ cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+ *endOffset = cursor.position();
+ break;
+ case ParagraphBoundary:
+ cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
+ *startOffset = cursor.position();
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ *endOffset = cursor.position();
+ break;
+ case NoBoundary: {
+ *startOffset = 0;
+ const QString txt = edit->toPlainText();
+ *endOffset = txt.count();
+ return txt; }
+ default:
+ qDebug("AccessibleTextAdaptor::textAtOffset: Unknown boundary type %d", boundaryType);
+ return QString();
+ }
+
+ return cursor.selectedText();
+}
+
+void QAccessibleTextEdit::removeSelection(int selectionIndex)
+{
+ if (selectionIndex != 0)
+ return;
+
+ QTextCursor cursor = textEdit()->textCursor();
+ cursor.clearSelection();
+ textEdit()->setTextCursor(cursor);
+}
+
+void QAccessibleTextEdit::setCursorPosition(int position)
+{
+ QTextCursor cursor = textEdit()->textCursor();
+ cursor.setPosition(position);
+ textEdit()->setTextCursor(cursor);
+}
+
+void QAccessibleTextEdit::setSelection(int selectionIndex, int startOffset, int endOffset)
+{
+ if (selectionIndex != 0)
+ return;
+
+ QTextCursor cursor = textEdit()->textCursor();
+ cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
+ cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
+ textEdit()->setTextCursor(cursor);
+}
+
+int QAccessibleTextEdit::characterCount()
+{
+ return textEdit()->toPlainText().count();
+}
+
+void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex)
+{
+ QTextEdit *edit = textEdit();
+
+ QTextCursor cursor(edit->document());
+ cursor.setPosition(startIndex);
+ QRect r = edit->cursorRect(cursor);
+
+ cursor.setPosition(endIndex);
+ r.setBottomRight(edit->cursorRect(cursor).bottomRight());
+
+ r.moveTo(r.x() + edit->horizontalScrollBar()->value(),
+ r.y() + edit->verticalScrollBar()->value());
+
+ // E V I L, but ensureVisible is not public
+ if (!QMetaObject::invokeMethod(edit, "_q_ensureVisible", Q_ARG(QRectF, r)))
+ qWarning("AccessibleTextEdit::scrollToSubstring failed!");
+}
+
+static QTextCursor cursorForRange(QTextEdit *textEdit, int startOffset, int endOffset)
+{
+ QTextCursor cursor(textEdit->document());
+ cursor.setPosition(startOffset, QTextCursor::MoveAnchor);
+ cursor.setPosition(endOffset, QTextCursor::KeepAnchor);
+
+ return cursor;
+}
+
+void QAccessibleTextEdit::copyText(int startOffset, int endOffset)
+{
+ QTextCursor cursor = cursorForRange(textEdit(), startOffset, endOffset);
+
+ if (!cursor.hasSelection())
+ return;
+
+// QApplication::clipboard()->setMimeData(new QTextEditMimeData(cursor.selection()));
+}
+
+void QAccessibleTextEdit::deleteText(int startOffset, int endOffset)
+{
+ QTextCursor cursor = cursorForRange(textEdit(), startOffset, endOffset);
+
+ cursor.removeSelectedText();
+}
+
+void QAccessibleTextEdit::insertText(int offset, const QString &text)
+{
+ QTextCursor cursor(textEdit()->document());
+ cursor.setPosition(offset);
+
+ cursor.insertText(text);
+}
+
+void QAccessibleTextEdit::cutText(int startOffset, int endOffset)
+{
+ QTextCursor cursor = cursorForRange(textEdit(), startOffset, endOffset);
+
+ if (!cursor.hasSelection())
+ return;
+
+// QApplication::clipboard()->setMimeData(new QTextEditMimeData(cursor.selection()));
+ cursor.removeSelectedText();
+}
+
+void QAccessibleTextEdit::pasteText(int offset)
+{
+ QTextEdit *edit = textEdit();
+
+ QTextCursor oldCursor = edit->textCursor();
+ QTextCursor newCursor = oldCursor;
+ newCursor.setPosition(offset);
+
+ edit->setTextCursor(newCursor);
+#ifndef QT_NO_CLIPBOARD
+ edit->paste();
+#endif
+ edit->setTextCursor(oldCursor);
+}
+
+void QAccessibleTextEdit::replaceText(int startOffset, int endOffset, const QString &text)
+{
+ QTextCursor cursor = cursorForRange(textEdit(), startOffset, endOffset);
+
+ cursor.removeSelectedText();
+ cursor.insertText(text);
+}
+
+void QAccessibleTextEdit::setAttributes(int startOffset, int endOffset, const QString &attributes)
+{
+ // TODO
+ Q_UNUSED(startOffset);
+ Q_UNUSED(endOffset);
+ Q_UNUSED(attributes);
+}
+
+#endif // QT_NO_TEXTEDIT
+
+#ifndef QT_NO_MAINWINDOW
+QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget)
+ : QAccessibleWidgetEx(widget, Application) { }
+
+QVariant QAccessibleMainWindow::invokeMethodEx(QAccessible::Method /*method*/, int /*child*/, const QVariantList & /*params*/)
+{
+ return QVariant();
+}
+
+int QAccessibleMainWindow::childCount() const
+{
+ QList<QWidget*> kids = childWidgets(mainWindow(), true);
+ return kids.count();
+}
+
+int QAccessibleMainWindow::indexOfChild(const QAccessibleInterface *iface) const
+{
+ QList<QWidget*> kids = childWidgets(mainWindow(), true);
+ int childIndex = kids.indexOf(static_cast<QWidget*>(iface->object()));
+ return childIndex == -1 ? -1 : ++childIndex;
+}
+
+int QAccessibleMainWindow::navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const
+{
+ if (relation == Child && entry >= 1) {
+ QList<QWidget*> kids = childWidgets(mainWindow(), true);
+ if (entry <= kids.count()) {
+ *iface = QAccessible::queryAccessibleInterface(kids.at(entry - 1));
+ return *iface ? 0 : -1;
+ }
+ }
+ return QAccessibleWidgetEx::navigate(relation, entry, iface);
+}
+
+int QAccessibleMainWindow::childAt(int x, int y) const
+{
+ QWidget *w = widget();
+ if (!w->isVisible())
+ return -1;
+ QPoint gp = w->mapToGlobal(QPoint(0, 0));
+ if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
+ return -1;
+
+ QWidgetList kids = childWidgets(mainWindow(), true);
+ QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y));
+ for (int i = 0; i < kids.size(); ++i) {
+ QWidget *child = kids.at(i);
+ if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
+ return i + 1;
+ }
+ }
+ return 0;
+}
+
+QMainWindow *QAccessibleMainWindow::mainWindow() const
+{
+ return qobject_cast<QMainWindow *>(object());
+}
+
+#endif //QT_NO_MAINWINDOW
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h
new file mode 100644
index 0000000000..64c2bde188
--- /dev/null
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h
@@ -0,0 +1,318 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLEWIDGETS_H
+#define QACCESSIBLEWIDGETS_H
+
+#include <QtGui/qaccessible2.h>
+#include <QtGui/qaccessiblewidget.h>
+
+#ifndef QT_NO_ACCESSIBILITY
+
+#include <QtCore/QPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QTextEdit;
+class QStackedWidget;
+class QToolBox;
+class QMdiArea;
+class QMdiSubWindow;
+class QWorkspace;
+class QRubberBand;
+class QTextBrowser;
+class QCalendarWidget;
+class QAbstractItemView;
+class QDockWidget;
+class QDockWidgetLayout;
+class QMainWindow;
+
+#ifndef QT_NO_TEXTEDIT
+class QAccessibleTextEdit : public QAccessibleWidgetEx, public QAccessibleTextInterface,
+ public QAccessibleEditableTextInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleTextEdit(QWidget *o);
+
+ QString text(Text t, int child) const;
+ void setText(Text t, int control, const QString &text);
+ Role role(int child) const;
+
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+
+ QRect rect(int child) const;
+ int childAt(int x, int y) const;
+
+ int childCount() const;
+
+ // QAccessibleTextInterface
+ void addSelection(int startOffset, int endOffset);
+ QString attributes(int offset, int *startOffset, int *endOffset);
+ int cursorPosition();
+ QRect characterRect(int offset, QAccessible2::CoordinateType coordType);
+ int selectionCount();
+ int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType);
+ void selection(int selectionIndex, int *startOffset, int *endOffset);
+ QString text(int startOffset, int endOffset);
+ QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset);
+ QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset);
+ QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset);
+ void removeSelection(int selectionIndex);
+ void setCursorPosition(int position);
+ void setSelection(int selectionIndex, int startOffset, int endOffset);
+ int characterCount();
+ void scrollToSubstring(int startIndex, int endIndex);
+
+ // QAccessibleEditableTextInterface
+ void copyText(int startOffset, int endOffset);
+ void deleteText(int startOffset, int endOffset);
+ void insertText(int offset, const QString &text);
+ void cutText(int startOffset, int endOffset);
+ void pasteText(int offset);
+ void replaceText(int startOffset, int endOffset, const QString &text);
+ void setAttributes(int startOffset, int endOffset, const QString &attributes);
+
+protected:
+ QTextEdit *textEdit() const;
+
+private:
+ int childOffset;
+};
+#endif // QT_NO_TEXTEDIT
+
+class QAccessibleStackedWidget : public QAccessibleWidgetEx
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleStackedWidget(QWidget *widget);
+
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childAt(int x, int y) const;
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+
+protected:
+ QStackedWidget *stackedWidget() const;
+};
+
+class QAccessibleToolBox : public QAccessibleWidgetEx
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleToolBox(QWidget *widget);
+
+ QString text(Text textType, int child) const;
+ void setText(Text textType, int child, const QString &text);
+ State state(int child) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+
+protected:
+ QToolBox *toolBox() const;
+};
+
+#ifndef QT_NO_MDIAREA
+class QAccessibleMdiArea : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleMdiArea(QWidget *widget);
+
+ State state(int child) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+
+protected:
+ QMdiArea *mdiArea() const;
+};
+
+class QAccessibleMdiSubWindow : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleMdiSubWindow(QWidget *widget);
+
+ QString text(Text textType, int child) const;
+ void setText(Text textType, int child, const QString &text);
+ State state(int child) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+ QRect rect(int child) const;
+ int childAt(int x, int y) const;
+
+protected:
+ QMdiSubWindow *mdiSubWindow() const;
+};
+#endif // QT_NO_MDIAREA
+
+#ifndef QT_NO_WORKSPACE
+class QAccessibleWorkspace : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleWorkspace(QWidget *widget);
+
+ State state(int child) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+
+protected:
+ QWorkspace *workspace() const;
+};
+#endif
+
+class QAccessibleDialogButtonBox : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleDialogButtonBox(QWidget *widget);
+
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+};
+
+#ifndef QT_NO_TEXTBROWSER
+class QAccessibleTextBrowser : public QAccessibleTextEdit
+{
+public:
+ explicit QAccessibleTextBrowser(QWidget *widget);
+
+ Role role(int child) const;
+};
+#endif // QT_NO_TEXTBROWSER
+
+#ifndef QT_NO_CALENDARWIDGET
+class QAccessibleCalendarWidget : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleCalendarWidget(QWidget *widget);
+
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
+ QRect rect(int child) const;
+ int childAt(int x, int y) const;
+
+protected:
+ QCalendarWidget *calendarWidget() const;
+
+private:
+ QAbstractItemView *calendarView() const;
+ QWidget *navigationBar() const;
+};
+#endif // QT_NO_CALENDARWIDGET
+
+#ifndef QT_NO_DOCKWIDGET
+class QAccessibleDockWidget: public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleDockWidget(QWidget *widget);
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int childCount() const;
+ QRect rect (int child ) const;
+ Role role(int child) const;
+ State state(int child) const;
+ int childAt(int x, int y) const;
+
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ QDockWidget *dockWidget() const;
+};
+
+class QAccessibleTitleBar : public QAccessibleInterface
+{
+public:
+ explicit QAccessibleTitleBar(QDockWidget *widget);
+ QString actionText(int action, Text t, int child) const;
+ bool doAction(int action, int child, const QVariantList& params = QVariantList());
+ int userActionCount ( int child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ int childCount() const;
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+ void setText(Text t, int child, const QString &text);
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ QRect rect (int child) const;
+ State state(int child) const;
+ int childAt(int x, int y) const;
+ QObject *object() const;
+ bool isValid() const;
+
+
+ QPointer<QDockWidget> m_dockWidget;
+
+ QDockWidget *dockWidget() const;
+ QDockWidgetLayout *dockWidgetLayout() const;
+};
+
+#endif // QT_NO_DOCKWIDGET
+
+#ifndef QT_NO_MAINWINDOW
+class QAccessibleMainWindow : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleMainWindow(QWidget *widget);
+
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ int childCount() const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface **iface) const;
+ int indexOfChild(const QAccessibleInterface *iface) const;
+ int childAt(int x, int y) const;
+ QMainWindow *mainWindow() const;
+
+};
+#endif //QT_NO_MAINWINDOW
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+#endif // QACESSIBLEWIDGETS_H
diff --git a/src/plugins/accessible/widgets/rangecontrols.cpp b/src/plugins/accessible/widgets/rangecontrols.cpp
new file mode 100644
index 0000000000..1f5407a631
--- /dev/null
+++ b/src/plugins/accessible/widgets/rangecontrols.cpp
@@ -0,0 +1,991 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "rangecontrols.h"
+
+#include <qslider.h>
+#include <qdial.h>
+#include <qspinbox.h>
+#include <qscrollbar.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qdebug.h>
+#include <qglobal.h>
+#include <QDoubleSpinBox>
+#include <QDial>
+#include <qmath.h>
+#include <private/qmath_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+extern QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
+#ifndef QT_NO_SCROLLBAR
+extern QStyleOptionSlider Q_GUI_EXPORT qt_qscrollbarStyleOption(QScrollBar *scrollBar);
+#endif
+#ifndef QT_NO_SLIDER
+extern QStyleOptionSlider Q_GUI_EXPORT qt_qsliderStyleOption(QSlider *slider);
+#endif
+
+#ifndef QT_NO_SPINBOX
+QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w)
+: QAccessibleWidgetEx(w, SpinBox)
+{
+ Q_ASSERT(abstractSpinBox());
+}
+
+/*!
+ Returns the underlying QAbstractSpinBox.
+*/
+QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const
+{
+ return qobject_cast<QAbstractSpinBox*>(object());
+}
+
+/*! \reimp */
+int QAccessibleAbstractSpinBox::childCount() const
+{
+ if (!abstractSpinBox()->isVisible())
+ return 0;
+ return ValueDown;
+}
+
+/*! \reimp */
+QRect QAccessibleAbstractSpinBox::rect(int child) const
+{
+ QRect rect;
+ if (!abstractSpinBox()->isVisible())
+ return rect;
+ QStyleOptionSpinBox so;
+ so.rect = widget()->rect();
+ switch(child) {
+ case Editor:
+ rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so,
+ QStyle::SC_SpinBoxEditField, widget());
+ break;
+ case ValueUp:
+ rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so,
+ QStyle::SC_SpinBoxUp, widget());
+ break;
+ case ValueDown:
+ rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so,
+ QStyle::SC_SpinBoxDown, widget());
+ break;
+ default:
+ rect = so.rect;
+ break;
+ }
+ QPoint tl = widget()->mapToGlobal(QPoint(0, 0));
+ return QRect(tl.x() + rect.x(), tl.y() + rect.y(), rect.width(), rect.height());
+}
+
+/*! \reimp */
+int QAccessibleAbstractSpinBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+
+ if (entry) switch (rel) {
+ case Child:
+ return entry <= childCount() ? entry : -1;
+ case QAccessible::Left:
+ return (entry == ValueUp || entry == ValueDown) ? Editor : -1;
+ case QAccessible::Right:
+ return entry == Editor ? ValueUp : -1;
+ case QAccessible::Up:
+ return entry == ValueDown ? ValueUp : -1;
+ case QAccessible::Down:
+ return entry == ValueUp ? ValueDown : -1;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::navigate(rel, entry, target);
+}
+
+/*! \reimp */
+QString QAccessibleAbstractSpinBox::text(Text t, int child) const
+{
+ if (!abstractSpinBox()->isVisible())
+ return QString();
+ switch (t) {
+ case Name:
+ switch (child) {
+ case ValueUp:
+ return QSpinBox::tr("More");
+ case ValueDown:
+ return QSpinBox::tr("Less");
+ }
+ break;
+ case Value:
+ if (child == Editor || child == SpinBoxSelf)
+ return abstractSpinBox()->text();
+ break;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::text(t, 0);
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleAbstractSpinBox::role(int child) const
+{
+ switch(child) {
+ case Editor:
+ return EditableText;
+ case ValueUp:
+ case ValueDown:
+ return PushButton;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::role(child);
+}
+
+/*! \reimp */
+bool QAccessibleAbstractSpinBox::doAction(int action, int child, const QVariantList &params)
+{
+ if (!widget()->isEnabled())
+ return false;
+
+ if (action == Press) {
+ switch(child) {
+ case ValueUp:
+ abstractSpinBox()->stepUp();
+ return true;
+ case ValueDown:
+ abstractSpinBox()->stepDown();
+ return true;
+ default:
+ break;
+ }
+ }
+ return QAccessibleWidgetEx::doAction(action, 0, params);
+}
+
+QVariant QAccessibleAbstractSpinBox::currentValue()
+{
+ QVariant result = abstractSpinBox()->property("value");
+ QVariant::Type type = result.type();
+
+ // IA2 only allows numeric types
+ if (type == QVariant::Int || type == QVariant::UInt || type == QVariant::LongLong
+ || type == QVariant::ULongLong || type == QVariant::Double)
+ return result;
+
+ return QVariant();
+}
+
+void QAccessibleAbstractSpinBox::setCurrentValue(const QVariant &value)
+{
+ abstractSpinBox()->setProperty("setValue", value);
+}
+
+QVariant QAccessibleAbstractSpinBox::maximumValue()
+{
+ return abstractSpinBox()->property("maximum");
+}
+
+QVariant QAccessibleAbstractSpinBox::minimumValue()
+{
+ return abstractSpinBox()->property("minimum");
+}
+
+QVariant QAccessibleAbstractSpinBox::invokeMethodEx(Method method, int child, const QVariantList &params)
+{
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods;
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
+ }
+ default:
+ return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
+ }
+}
+
+
+/*!
+ \class QAccessibleSpinBox
+ \brief The QAccessibleSpinBox class implements the QAccessibleInterface for spinbox widgets.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ \enum QAccessibleAbstractSpinBox::SpinBoxElements
+
+ This enum identifies the components of the spin box.
+
+ \value SpinBoxSelf The spin box as a whole
+ \value Editor The line edit sub-widget.
+ \value ValueUp The up sub-widget (i.e. the up arrow or + button)
+ \value ValueDown The down sub-widget (i.e. the down arrow or - button)
+*/
+
+/*!
+ Constructs a QAccessibleSpinWidget object for \a w.
+*/
+QAccessibleSpinBox::QAccessibleSpinBox(QWidget *w)
+: QAccessibleAbstractSpinBox(w)
+{
+ Q_ASSERT(spinBox());
+ addControllingSignal(QLatin1String("valueChanged(int)"));
+ addControllingSignal(QLatin1String("valueChanged(QString)"));
+}
+
+/*!
+ Returns the underlying QSpinBox.
+*/
+QSpinBox *QAccessibleSpinBox::spinBox() const
+{
+ return qobject_cast<QSpinBox*>(object());
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleSpinBox::state(int child) const
+{
+ State state = QAccessibleAbstractSpinBox::state(child);
+ switch(child) {
+ case ValueUp:
+ if (spinBox()->value() >= spinBox()->maximum())
+ state |= Unavailable;
+ return state;
+ case ValueDown:
+ if (spinBox()->value() <= spinBox()->minimum())
+ state |= Unavailable;
+ return state;
+ default:
+ break;
+ }
+ return state;
+}
+
+/*! \reimp */
+bool QAccessibleSpinBox::doAction(int action, int child, const QVariantList &params)
+{
+ if (!widget()->isEnabled())
+ return false;
+
+ if (action == Press) {
+ switch(child) {
+ case ValueUp:
+ if (spinBox()->value() >= spinBox()->maximum())
+ return false;
+ spinBox()->stepUp();
+ return true;
+ case ValueDown:
+ if (spinBox()->value() <= spinBox()->minimum())
+ return false;
+ spinBox()->stepDown();
+ return true;
+ default:
+ break;
+ }
+ }
+ return QAccessibleAbstractSpinBox::doAction(action, 0, params);
+}
+
+// ================================== QAccessibleDoubleSpinBox ==================================
+QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget)
+ : QAccessibleWidgetEx(widget, SpinBox)
+{
+ Q_ASSERT(qobject_cast<QDoubleSpinBox *>(widget));
+ addControllingSignal(QLatin1String("valueChanged(double)"));
+ addControllingSignal(QLatin1String("valueChanged(QString)"));
+}
+
+/*!
+ Returns the underlying QDoubleSpinBox.
+*/
+QDoubleSpinBox *QAccessibleDoubleSpinBox::doubleSpinBox() const
+{
+ return static_cast<QDoubleSpinBox*>(object());
+}
+
+/*! \reimp */
+int QAccessibleDoubleSpinBox::childCount() const
+{
+ if (!doubleSpinBox()->isVisible())
+ return 0;
+ return ValueDown;
+}
+
+/*! \reimp */
+QRect QAccessibleDoubleSpinBox::rect(int child) const
+{
+ QRect rect;
+ if (!doubleSpinBox()->isVisible())
+ return rect;
+ QStyleOptionSpinBox spinBoxOption;
+ spinBoxOption.initFrom(doubleSpinBox());
+ switch (child) {
+ case Editor:
+ rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption,
+ QStyle::SC_SpinBoxEditField, doubleSpinBox());
+ break;
+ case ValueUp:
+ rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption,
+ QStyle::SC_SpinBoxUp, doubleSpinBox());
+ break;
+ case ValueDown:
+ rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption,
+ QStyle::SC_SpinBoxDown, doubleSpinBox());
+ break;
+ default:
+ rect = spinBoxOption.rect;
+ break;
+ }
+ const QPoint globalPos = doubleSpinBox()->mapToGlobal(QPoint(0, 0));
+ return QRect(globalPos.x() + rect.x(), globalPos.y() + rect.y(), rect.width(), rect.height());
+}
+
+/*! \reimp */
+int QAccessibleDoubleSpinBox::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
+{
+ if (entry <= 0)
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+
+ *target = 0;
+ switch (relation) {
+ case Child:
+ return entry <= childCount() ? entry : -1;
+ case QAccessible::Left:
+ return (entry == ValueUp || entry == ValueDown) ? Editor : -1;
+ case QAccessible::Right:
+ return entry == Editor ? ValueUp : -1;
+ case QAccessible::Up:
+ return entry == ValueDown ? ValueUp : -1;
+ case QAccessible::Down:
+ return entry == ValueUp ? ValueDown : -1;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::navigate(relation, entry, target);
+}
+
+QVariant QAccessibleDoubleSpinBox::invokeMethodEx(QAccessible::Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+/*! \reimp */
+QString QAccessibleDoubleSpinBox::text(Text textType, int child) const
+{
+ if (!doubleSpinBox()->isVisible())
+ return QString();
+ switch (textType) {
+ case Name:
+ if (child == ValueUp)
+ return QDoubleSpinBox::tr("More");
+ else if (child == ValueDown)
+ return QDoubleSpinBox::tr("Less");
+ break;
+ case Value:
+ if (child == Editor || child == SpinBoxSelf)
+ return doubleSpinBox()->textFromValue(doubleSpinBox()->value());
+ break;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::text(textType, 0);
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleDoubleSpinBox::role(int child) const
+{
+ switch (child) {
+ case Editor:
+ return EditableText;
+ case ValueUp:
+ case ValueDown:
+ return PushButton;
+ default:
+ break;
+ }
+ return QAccessibleWidgetEx::role(child);
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleDoubleSpinBox::state(int child) const
+{
+ State state = QAccessibleWidgetEx::state(child);
+ switch (child) {
+ case ValueUp:
+ if (doubleSpinBox()->value() >= doubleSpinBox()->maximum())
+ state |= Unavailable;
+ break;
+ case ValueDown:
+ if (doubleSpinBox()->value() <= doubleSpinBox()->minimum())
+ state |= Unavailable;
+ break;
+ default:
+ break;
+ }
+ return state;
+}
+#endif // QT_NO_SPINBOX
+
+#ifndef QT_NO_SCROLLBAR
+/*!
+ \class QAccessibleScrollBar
+ \brief The QAccessibleScrollBar class implements the QAccessibleInterface for scroll bars.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ \enum QAccessibleScrollBar::ScrollBarElements
+
+ This enum identifies the components of the scroll bar.
+
+ \value ScrollBarSelf The scroll bar as a whole.
+ \value LineUp The up arrow button.
+ \value PageUp The area between the position and the up arrow button.
+ \value Position The position marking rectangle.
+ \value PageDown The area between the position and the down arrow button.
+ \value LineDown The down arrow button.
+*/
+
+/*!
+ Constructs a QAccessibleScrollBar object for \a w.
+ \a name is propagated to the QAccessibleWidgetEx constructor.
+*/
+QAccessibleScrollBar::QAccessibleScrollBar(QWidget *w)
+: QAccessibleAbstractSlider(w, ScrollBar)
+{
+ Q_ASSERT(scrollBar());
+ addControllingSignal(QLatin1String("valueChanged(int)"));
+}
+
+/*! Returns the scroll bar. */
+QScrollBar *QAccessibleScrollBar::scrollBar() const
+{
+ return qobject_cast<QScrollBar*>(object());
+}
+
+/*! \reimp */
+QRect QAccessibleScrollBar::rect(int child) const
+{
+ if (!scrollBar()->isVisible())
+ return QRect();
+
+ QStyle::SubControl subControl;
+ switch (child) {
+ case LineUp:
+ subControl = QStyle ::SC_ScrollBarSubLine;
+ break;
+ case PageUp:
+ subControl = QStyle::SC_ScrollBarSubPage;
+ break;
+ case Position:
+ subControl = QStyle::SC_ScrollBarSlider;
+ break;
+ case PageDown:
+ subControl = QStyle::SC_ScrollBarAddPage;
+ break;
+ case LineDown:
+ subControl = QStyle::SC_ScrollBarAddLine;
+ break;
+ default:
+ return QAccessibleAbstractSlider::rect(child);
+ }
+
+ const QStyleOptionSlider option = qt_qscrollbarStyleOption(scrollBar());
+ const QRect rect = scrollBar()->style()->subControlRect(QStyle::CC_ScrollBar, &option,
+ subControl, scrollBar());
+ const QPoint tp = scrollBar()->mapToGlobal(QPoint(0,0));
+ return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height());
+}
+
+/*! \reimp */
+int QAccessibleScrollBar::childCount() const
+{
+ if (!scrollBar()->isVisible())
+ return 0;
+ return LineDown;
+}
+
+/*! \reimp */
+QString QAccessibleScrollBar::text(Text t, int child) const
+{
+ if (!scrollBar()->isVisible())
+ return QString();
+ switch (t) {
+ case Value:
+ if (!child || child == Position)
+ return QString::number(scrollBar()->value());
+ return QString();
+ case Name:
+ switch (child) {
+ case LineUp:
+ return QScrollBar::tr("Line up");
+ case PageUp:
+ return QScrollBar::tr("Page up");
+ case Position:
+ return QScrollBar::tr("Position");
+ case PageDown:
+ return QScrollBar::tr("Page down");
+ case LineDown:
+ return QScrollBar::tr("Line down");
+ }
+ break;
+ default:
+ break;
+ }
+ return QAccessibleAbstractSlider::text(t, child);
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleScrollBar::role(int child) const
+{
+ switch (child) {
+ case LineUp:
+ case PageUp:
+ case PageDown:
+ case LineDown:
+ return PushButton;
+ case Position:
+ return Indicator;
+ default:
+ return ScrollBar;
+ }
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleScrollBar::state(int child) const
+{
+ const State parentState = QAccessibleAbstractSlider::state(0);
+
+ if (child == 0)
+ return parentState;
+
+ // Inherit the Invisible state from parent.
+ State state = parentState & QAccessible::Invisible;
+
+ // Disable left/right if we are at the minimum/maximum.
+ const QScrollBar * const scrollBar = QAccessibleScrollBar::scrollBar();
+ switch (child) {
+ case LineUp:
+ case PageUp:
+ if (scrollBar->value() <= scrollBar->minimum())
+ state |= Unavailable;
+ break;
+ case LineDown:
+ case PageDown:
+ if (scrollBar->value() >= scrollBar->maximum())
+ state |= Unavailable;
+ break;
+ case Position:
+ default:
+ break;
+ }
+
+ return state;
+}
+#endif // QT_NO_SCROLLBAR
+
+#ifndef QT_NO_SLIDER
+/*!
+ \class QAccessibleSlider
+ \brief The QAccessibleSlider class implements the QAccessibleInterface for sliders.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ \enum QAccessibleSlider::SliderElements
+
+ This enum identifies the components of the slider.
+
+ \value SliderSelf The slider as a whole.
+ \value PageLeft The area to the left of the position.
+ \value Position The position indicator.
+ \value PageRight The area to the right of the position.
+*/
+
+/*!
+ Constructs a QAccessibleScrollBar object for \a w.
+ \a name is propagated to the QAccessibleWidgetEx constructor.
+*/
+QAccessibleSlider::QAccessibleSlider(QWidget *w)
+: QAccessibleAbstractSlider(w)
+{
+ Q_ASSERT(slider());
+ addControllingSignal(QLatin1String("valueChanged(int)"));
+}
+
+/*! Returns the slider. */
+QSlider *QAccessibleSlider::slider() const
+{
+ return qobject_cast<QSlider*>(object());
+}
+
+/*! \reimp */
+QRect QAccessibleSlider::rect(int child) const
+{
+ QRect rect;
+ if (!slider()->isVisible())
+ return rect;
+ const QStyleOptionSlider option = qt_qsliderStyleOption(slider());
+ QRect srect = slider()->style()->subControlRect(QStyle::CC_Slider, &option,
+ QStyle::SC_SliderHandle, slider());
+
+ switch (child) {
+ case PageLeft:
+ if (slider()->orientation() == Qt::Vertical)
+ rect = QRect(0, 0, slider()->width(), srect.y());
+ else
+ rect = QRect(0, 0, srect.x(), slider()->height());
+ break;
+ case Position:
+ rect = srect;
+ break;
+ case PageRight:
+ if (slider()->orientation() == Qt::Vertical)
+ rect = QRect(0, srect.y() + srect.height(), slider()->width(), slider()->height()- srect.y() - srect.height());
+ else
+ rect = QRect(srect.x() + srect.width(), 0, slider()->width() - srect.x() - srect.width(), slider()->height());
+ break;
+ default:
+ return QAccessibleAbstractSlider::rect(child);
+ }
+
+ QPoint tp = slider()->mapToGlobal(QPoint(0,0));
+ return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height());
+}
+
+/*! \reimp */
+int QAccessibleSlider::childCount() const
+{
+ if (!slider()->isVisible())
+ return 0;
+ return PageRight;
+}
+
+/*! \reimp */
+QString QAccessibleSlider::text(Text t, int child) const
+{
+ if (!slider()->isVisible())
+ return QString();
+ switch (t) {
+ case Value:
+ if (!child || child == 2)
+ return QString::number(slider()->value());
+ return QString();
+ case Name:
+ switch (child) {
+ case PageLeft:
+ return slider()->orientation() == Qt::Horizontal ?
+ QSlider::tr("Page left") : QSlider::tr("Page up");
+ case Position:
+ return QSlider::tr("Position");
+ case PageRight:
+ return slider()->orientation() == Qt::Horizontal ?
+ QSlider::tr("Page right") : QSlider::tr("Page down");
+ }
+ break;
+ default:
+ break;
+ }
+ return QAccessibleAbstractSlider::text(t, child);
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleSlider::role(int child) const
+{
+ switch (child) {
+ case PageLeft:
+ case PageRight:
+ return PushButton;
+ case Position:
+ return Indicator;
+ default:
+ return Slider;
+ }
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleSlider::state(int child) const
+{
+ const State parentState = QAccessibleAbstractSlider::state(0);
+
+ if (child == 0)
+ return parentState;
+
+ // Inherit the Invisible state from parent.
+ State state = parentState & QAccessible::Invisible;
+
+ // Disable left/right if we are at the minimum/maximum.
+ const QSlider * const slider = QAccessibleSlider::slider();
+ switch (child) {
+ case PageLeft:
+ if (slider->value() <= slider->minimum())
+ state |= Unavailable;
+ break;
+ case PageRight:
+ if (slider->value() >= slider->maximum())
+ state |= Unavailable;
+ break;
+ case Position:
+ default:
+ break;
+ }
+
+ return state;
+}
+
+/*!
+ \fn int QAccessibleSlider::defaultAction(int child) const
+
+ Returns the default action for the given \a child. The base class
+ implementation returns 0.
+*/
+int QAccessibleSlider::defaultAction(int /*child*/) const
+{
+/*
+ switch (child) {
+ case SliderSelf:
+ return SetFocus;
+ case PageLeft:
+ return Press;
+ case PageRight:
+ return Press;
+ }
+*/
+ return 0;
+}
+
+/*! \internal */
+QString QAccessibleSlider::actionText(int /*action*/, Text /*t*/, int /*child*/) const
+{
+ return QLatin1String("");
+}
+
+QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, Role r)
+ : QAccessibleWidgetEx(w, r)
+{
+ Q_ASSERT(qobject_cast<QAbstractSlider *>(w));
+}
+
+QVariant QAccessibleAbstractSlider::invokeMethodEx(Method method, int child, const QVariantList &params)
+{
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods;
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
+ }
+ default:
+ return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
+ }
+}
+
+QVariant QAccessibleAbstractSlider::currentValue()
+{
+ return abstractSlider()->value();
+}
+
+void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value)
+{
+ abstractSlider()->setValue(value.toInt());
+}
+
+QVariant QAccessibleAbstractSlider::maximumValue()
+{
+ return abstractSlider()->maximum();
+}
+
+QVariant QAccessibleAbstractSlider::minimumValue()
+{
+ return abstractSlider()->minimum();
+}
+
+QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const
+{
+ return static_cast<QAbstractSlider *>(object());
+}
+
+#endif // QT_NO_SLIDER
+
+#ifndef QT_NO_DIAL
+// ======================================= QAccessibleDial ======================================
+QAccessibleDial::QAccessibleDial(QWidget *widget)
+ : QAccessibleWidgetEx(widget, Dial)
+{
+ Q_ASSERT(qobject_cast<QDial *>(widget));
+ addControllingSignal(QLatin1String("valueChanged(int)"));
+}
+
+QRect QAccessibleDial::rect(int child) const
+{
+ QRect rect;
+ if (!dial()->isVisible())
+ return rect;
+ switch (child) {
+ case Self:
+ return QAccessibleWidgetEx::rect(child);
+ case SpeedoMeter: {
+ // Mixture from qcommonstyle.cpp (focus rect).
+ int width = dial()->width();
+ int height = dial()->height();
+ qreal radius = qMin(width, height) / 2.0;
+ qreal delta = radius / 6.0;
+ qreal dx = delta + (width - 2 * radius) / 2.0;
+ qreal dy = delta + (height - 2 * radius) / 2.0;
+ rect = QRect(int(dx), int(dy), int(radius * 2 - 2 * delta), int(radius * 2 - 2 * delta));
+ if (dial()->notchesVisible()) {
+ rect.translate(int(-radius / 6), int(-radius / 6));
+ rect.setWidth(rect.width() + int(radius / 3));
+ rect.setHeight(rect.height() + int(radius / 3));
+ }
+ break;
+ }
+ case SliderHandle: {
+ // Mixture from qcommonstyle.cpp and qdial.cpp.
+ int sliderValue = !dial()->invertedAppearance() ? dial()->value()
+ : (dial()->maximum() - dial()->value());
+ qreal angle = 0;
+ if (dial()->maximum() == dial()->minimum()) {
+ angle = Q_PI / 2;
+ } else if (dial()->wrapping()) {
+ angle = Q_PI * 3 / 2 - (sliderValue - dial()->minimum()) * 2 * Q_PI
+ / (dial()->maximum() - dial()->minimum());
+ } else {
+ angle = (Q_PI * 8 - (sliderValue - dial()->minimum()) * 10 * Q_PI
+ / (dial()->maximum() - dial()->minimum())) / 6;
+ }
+
+ int width = dial()->rect().width();
+ int height = dial()->rect().height();
+ int radius = qMin(width, height) / 2;
+ int xc = width / 2;
+ int yc = height / 2;
+ int bigLineSize = radius / 6;
+ if (bigLineSize < 4)
+ bigLineSize = 4;
+ if (bigLineSize > radius / 2)
+ bigLineSize = radius / 2;
+ int len = radius - bigLineSize - 5;
+ if (len < 5)
+ len = 5;
+ int back = len / 2;
+
+ QPolygonF arrow(3);
+ arrow[0] = QPointF(0.5 + xc + len * qCos(angle),
+ 0.5 + yc - len * qSin(angle));
+ arrow[1] = QPointF(0.5 + xc + back * qCos(angle + Q_PI * 5 / 6),
+ 0.5 + yc - back * qSin(angle + Q_PI * 5 / 6));
+ arrow[2] = QPointF(0.5 + xc + back * qCos(angle - Q_PI * 5 / 6),
+ 0.5 + yc - back * qSin(angle - Q_PI * 5 / 6));
+ rect = arrow.boundingRect().toRect();
+ break;
+ }
+ default:
+ return QRect();
+ }
+
+ QPoint globalPos = dial()->mapToGlobal(QPoint(0,0));
+ return QRect(globalPos.x() + rect.x(), globalPos.y() + rect.y(), rect.width(), rect.height());
+}
+
+int QAccessibleDial::childCount() const
+{
+ if (!dial()->isVisible())
+ return 0;
+ return SliderHandle;
+}
+
+QString QAccessibleDial::text(Text textType, int child) const
+{
+ if (!dial()->isVisible())
+ return QString();
+ if (textType == Value && child >= Self && child <= SliderHandle)
+ return QString::number(dial()->value());
+ if (textType == Name) {
+ switch (child) {
+ case Self:
+ if (!widget()->accessibleName().isEmpty())
+ return widget()->accessibleName();
+ return QDial::tr("QDial");
+ case SpeedoMeter:
+ return QDial::tr("SpeedoMeter");
+ case SliderHandle:
+ return QDial::tr("SliderHandle");
+ }
+ }
+ return QAccessibleWidgetEx::text(textType, child);
+}
+
+QAccessible::Role QAccessibleDial::role(int child) const
+{
+ if (child == SpeedoMeter)
+ return Slider;
+ else if (child == SliderHandle)
+ return Indicator;
+ return QAccessibleWidgetEx::role(child);
+}
+
+QAccessible::State QAccessibleDial::state(int child) const
+{
+ const State parentState = QAccessibleWidgetEx::state(0);
+ if (child == SliderHandle)
+ return parentState | HotTracked;
+ return parentState;
+}
+
+QVariant QAccessibleDial::invokeMethodEx(Method, int, const QVariantList &)
+{
+ return QVariant();
+}
+
+QDial *QAccessibleDial::dial() const
+{
+ return static_cast<QDial*>(object());
+}
+#endif // QT_NO_DIAL
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h
new file mode 100644
index 0000000000..f565d8e888
--- /dev/null
+++ b/src/plugins/accessible/widgets/rangecontrols.h
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RANGECONTROLS_H
+#define RANGECONTROLS_H
+
+#include <QtGui/qaccessiblewidget.h>
+#include <QtGui/qaccessible2.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QAbstractSpinBox;
+class QAbstractSlider;
+class QScrollBar;
+class QSlider;
+class QSpinBox;
+class QDoubleSpinBox;
+class QDial;
+
+#ifndef QT_NO_SPINBOX
+class QAccessibleAbstractSpinBox: public QAccessibleWidgetEx, public QAccessibleValueInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleAbstractSpinBox(QWidget *w);
+
+ enum SpinBoxElements {
+ SpinBoxSelf = 0,
+ Editor,
+ ValueUp,
+ ValueDown
+ };
+
+ int childCount() const;
+ QRect rect(int child) const;
+
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+
+ bool doAction(int action, int child, const QVariantList &params);
+
+ QVariant invokeMethodEx(Method method, int child, const QVariantList &params);
+
+ // QAccessibleValueInterface
+ QVariant currentValue();
+ void setCurrentValue(const QVariant &value);
+ QVariant maximumValue();
+ QVariant minimumValue();
+
+protected:
+ QAbstractSpinBox *abstractSpinBox() const;
+};
+
+class QAccessibleSpinBox : public QAccessibleAbstractSpinBox
+{
+public:
+ explicit QAccessibleSpinBox(QWidget *w);
+
+ State state(int child) const;
+
+ bool doAction(int action, int child, const QVariantList &params);
+
+protected:
+ QSpinBox *spinBox() const;
+};
+
+class QAccessibleDoubleSpinBox : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleDoubleSpinBox(QWidget *widget);
+
+ enum DoubleSpinBoxElements {
+ SpinBoxSelf = 0,
+ Editor,
+ ValueUp,
+ ValueDown
+ };
+
+ int childCount() const;
+ QRect rect(int child) const;
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+protected:
+ QDoubleSpinBox *doubleSpinBox() const;
+};
+#endif // QT_NO_SPINBOX
+
+class QAccessibleAbstractSlider: public QAccessibleWidgetEx, public QAccessibleValueInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleAbstractSlider(QWidget *w, Role r = Slider);
+
+ QVariant invokeMethodEx(Method method, int child, const QVariantList &params);
+
+ // QAccessibleValueInterface
+ QVariant currentValue();
+ void setCurrentValue(const QVariant &value);
+ QVariant maximumValue();
+ QVariant minimumValue();
+
+protected:
+ QAbstractSlider *abstractSlider() const;
+};
+
+#ifndef QT_NO_SCROLLBAR
+class QAccessibleScrollBar : public QAccessibleAbstractSlider
+{
+public:
+ explicit QAccessibleScrollBar(QWidget *w);
+
+ enum ScrollBarElements {
+ ScrollBarSelf = 0,
+ LineUp,
+ PageUp,
+ Position,
+ PageDown,
+ LineDown
+ };
+
+ int childCount() const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+protected:
+ QScrollBar *scrollBar() const;
+};
+#endif // QT_NO_SCROLLBAR
+
+#ifndef QT_NO_SLIDER
+class QAccessibleSlider : public QAccessibleAbstractSlider
+{
+public:
+ explicit QAccessibleSlider(QWidget *w);
+
+ enum SliderElements {
+ SliderSelf = 0,
+ PageLeft,
+ Position,
+ PageRight
+ };
+
+ int childCount() const;
+
+ QRect rect(int child) const;
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ int defaultAction(int child) const;
+ QString actionText(int action, Text t, int child) const;
+
+protected:
+ QSlider *slider() const;
+};
+#endif // QT_NO_SLIDER
+
+#ifndef QT_NO_DIAL
+class QAccessibleDial : public QAccessibleWidgetEx
+{
+public:
+ explicit QAccessibleDial(QWidget *w);
+
+ enum DialElements {
+ Self = 0,
+ SpeedoMeter,
+ SliderHandle
+ };
+
+ int childCount() const;
+ QRect rect(int child) const;
+ QString text(Text textType, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+ QVariant invokeMethodEx(Method method, int child, const QVariantList &params);
+
+protected:
+ QDial *dial() const;
+};
+#endif // QT_NO_DIAL
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+#endif // RANGECONTROLS_H
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
new file mode 100644
index 0000000000..21d2d671f3
--- /dev/null
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -0,0 +1,888 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simplewidgets.h"
+
+#include <qabstractbutton.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qprogressbar.h>
+#include <qradiobutton.h>
+#include <qtoolbutton.h>
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qlcdnumber.h>
+#include <qlineedit.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+
+#ifdef Q_OS_MAC
+#include <qfocusframe.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+using namespace QAccessible2;
+extern QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel = false);
+
+QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
+QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
+
+/*!
+ \class QAccessibleButton
+ \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ Creates a QAccessibleButton object for \a w.
+ \a role is propagated to the QAccessibleWidgetEx constructor.
+*/
+QAccessibleButton::QAccessibleButton(QWidget *w, Role role)
+: QAccessibleWidgetEx(w, role)
+{
+ Q_ASSERT(button());
+ if (button()->isCheckable())
+ addControllingSignal(QLatin1String("toggled(bool)"));
+ else
+ addControllingSignal(QLatin1String("clicked()"));
+}
+
+/*! Returns the button. */
+QAbstractButton *QAccessibleButton::button() const
+{
+ return qobject_cast<QAbstractButton*>(object());
+}
+
+/*! \reimp */
+QString QAccessibleButton::actionText(int action, Text text, int child) const
+{
+ if (child)
+ return QString();
+
+ if (text == Name) switch (action) {
+ case Press:
+ case DefaultAction: // press, checking or open
+ switch (role(0)) {
+ case ButtonMenu:
+ return QPushButton::tr("Open");
+ case CheckBox:
+ {
+ if (state(child) & Checked)
+ return QCheckBox::tr("Uncheck");
+ QCheckBox *cb = qobject_cast<QCheckBox*>(object());
+ if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
+ return QCheckBox::tr("Check");
+ return QCheckBox::tr("Toggle");
+ }
+ break;
+ case RadioButton:
+ return QRadioButton::tr("Check");
+ default:
+ break;
+ }
+ break;
+ }
+ return QAccessibleWidgetEx::actionText(action, text, child);
+}
+
+/*! \reimp */
+bool QAccessibleButton::doAction(int action, int child, const QVariantList &params)
+{
+ if (child || !widget()->isEnabled() || !widget()->isVisible())
+ return false;
+
+ switch (action) {
+ case DefaultAction:
+ case Press:
+ {
+#ifndef QT_NO_MENU
+ QPushButton *pb = qobject_cast<QPushButton*>(object());
+ if (pb && pb->menu())
+ pb->showMenu();
+ else
+#endif
+ button()->animateClick();
+ }
+ return true;
+ }
+ return QAccessibleWidgetEx::doAction(action, child, params);
+}
+
+/*! \reimp */
+QString QAccessibleButton::text(Text t, int child) const
+{
+ QString str;
+ if (!widget()->isVisible())
+ return str;
+
+ switch (t) {
+ case Accelerator:
+ {
+#ifndef QT_NO_SHORTCUT
+ QPushButton *pb = qobject_cast<QPushButton*>(object());
+ if (pb && pb->isDefault())
+ str = (QString)QKeySequence(Qt::Key_Enter);
+#endif
+ if (str.isEmpty())
+ str = qt_accHotKey(button()->text());
+ }
+ break;
+ case Name:
+ str = widget()->accessibleName();
+ if (str.isEmpty())
+ str = button()->text();
+ break;
+ default:
+ break;
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, child);;
+ return qt_accStripAmp(str);
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleButton::state(int child) const
+{
+ State state = QAccessibleWidgetEx::state(child);
+
+ QAbstractButton *b = button();
+ QCheckBox *cb = qobject_cast<QCheckBox *>(b);
+ if (b->isChecked())
+ state |= Checked;
+ else if (cb && cb->checkState() == Qt::PartiallyChecked)
+ state |= Mixed;
+ if (b->isDown())
+ state |= Pressed;
+ QPushButton *pb = qobject_cast<QPushButton*>(b);
+ if (pb) {
+ if (pb->isDefault())
+ state |= DefaultButton;
+#ifndef QT_NO_MENU
+ if (pb->menu())
+ state |= HasPopup;
+#endif
+ }
+
+ return state;
+}
+
+int QAccessibleButton::actionCount()
+{
+ return 1;
+}
+
+void QAccessibleButton::doAction(int actionIndex)
+{
+ switch (actionIndex) {
+ case 0:
+ button()->click();
+ break;
+ }
+}
+
+QString QAccessibleButton::description(int actionIndex)
+{
+ switch (actionIndex) {
+ case 0:
+ return QLatin1String("Clicks the button.");
+ default:
+ return QString();
+ }
+}
+
+QString QAccessibleButton::name(int actionIndex)
+{
+ switch (actionIndex) {
+ case 0:
+ return QLatin1String("Press");
+ default:
+ return QString();
+ }
+}
+
+QString QAccessibleButton::localizedName(int actionIndex)
+{
+ switch (actionIndex) {
+ case 0:
+ return tr("Press");
+ default:
+ return QString();
+ }
+}
+
+QStringList QAccessibleButton::keyBindings(int actionIndex)
+{
+ switch (actionIndex) {
+#ifndef QT_NO_SHORTCUT
+ case 0:
+ return QStringList() << button()->shortcut().toString();
+#endif
+ default:
+ return QStringList();
+ }
+}
+
+#ifndef QT_NO_TOOLBUTTON
+/*!
+ \class QAccessibleToolButton
+ \brief The QAccessibleToolButton class implements the QAccessibleInterface for tool buttons.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ \enum QAccessibleToolButton::ToolButtonElements
+
+ This enum identifies the components of the tool button.
+
+ \value ToolButtonSelf The tool button as a whole.
+ \value ButtonExecute The button.
+ \value ButtonDropMenu The drop down menu.
+*/
+
+/*!
+ Creates a QAccessibleToolButton object for \a w.
+ \a role is propagated to the QAccessibleWidgetEx constructor.
+*/
+QAccessibleToolButton::QAccessibleToolButton(QWidget *w, Role role)
+: QAccessibleButton(w, role)
+{
+ Q_ASSERT(toolButton());
+}
+
+/*! Returns the button. */
+QToolButton *QAccessibleToolButton::toolButton() const
+{
+ return qobject_cast<QToolButton*>(object());
+}
+
+/*!
+ Returns true if this tool button is a split button.
+*/
+bool QAccessibleToolButton::isSplitButton() const
+{
+#ifndef QT_NO_MENU
+ return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup;
+#else
+ return false;
+#endif
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleToolButton::role(int child) const
+{
+ if (isSplitButton()) switch(child) {
+ case ButtonExecute:
+ return PushButton;
+ case ButtonDropMenu:
+ return ButtonMenu;
+ }
+ return QAccessibleButton::role(child);
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleToolButton::state(int child) const
+{
+ QAccessible::State st = QAccessibleButton::state(child);
+ if (toolButton()->autoRaise())
+ st |= HotTracked;
+#ifndef QT_NO_MENU
+ if (toolButton()->menu() && child != ButtonExecute)
+ st |= HasPopup;
+#endif
+ return st;
+}
+
+/*! \reimp */
+int QAccessibleToolButton::childCount() const
+{
+ if (!toolButton()->isVisible())
+ return 0;
+ return isSplitButton() ? ButtonDropMenu : 0;
+}
+
+/*!
+ \internal
+
+ Returns the rectangle occupied by this button, depending on \a
+ child.
+*/
+QRect QAccessibleToolButton::rect(int child) const
+{
+ if (!toolButton()->isVisible())
+ return QRect();
+ if (!child)
+ return QAccessibleButton::rect(child);
+
+ QStyleOptionToolButton opt;
+ opt.init(widget());
+ QRect subrect = widget()->style()->subControlRect(QStyle::CC_ToolButton, &opt,
+ QStyle::SC_ToolButtonMenu, toolButton());
+
+ if (child == ButtonExecute)
+ subrect = QRect(0, 0, subrect.x(), widget()->height());
+
+ QPoint ntl = widget()->mapToGlobal(subrect.topLeft());
+ subrect.moveTopLeft(ntl);
+ return subrect;
+}
+
+/*!
+ \internal
+
+ Returns the button's text label, depending on the text \a t, and
+ the \a child.
+*/
+QString QAccessibleToolButton::text(Text t, int child) const
+{
+ QString str;
+ if (!toolButton()->isVisible())
+ return str;
+
+ switch (t) {
+ case Name:
+ str = toolButton()->text();
+ if (str.isEmpty())
+ str = toolButton()->text();
+ break;
+ default:
+ break;
+ }
+ if (str.isEmpty())
+ str = QAccessibleButton::text(t, child);;
+ return qt_accStripAmp(str);
+}
+
+/*!
+ \internal
+
+ Returns the number of actions which is 0, 1, or 2, in part
+ depending on \a child.
+*/
+int QAccessibleToolButton::actionCount(int child) const
+{
+ // each subelement has one action
+ if (child)
+ return isSplitButton() ? 1 : 0;
+ int ac = widget()->focusPolicy() != Qt::NoFocus ? 1 : 0;
+ // button itself has two actions if a menu button
+#ifndef QT_NO_MENU
+ return ac + (toolButton()->menu() ? 2 : 1);
+#else
+ return ac + 1;
+#endif
+}
+
+/*!
+ \internal
+
+ If \a text is \c Name, then depending on the \a child or the \a
+ action, an action text is returned. This is a translated string
+ which in English is one of "Press", "Open", or "Set Focus". If \a
+ text is not \c Name, an empty string is returned.
+*/
+QString QAccessibleToolButton::actionText(int action, Text text, int child) const
+{
+ if (text == Name) switch(child) {
+ case ButtonExecute:
+ return QToolButton::tr("Press");
+ case ButtonDropMenu:
+ return QToolButton::tr("Open");
+ default:
+ switch(action) {
+ case 0:
+ return QToolButton::tr("Press");
+ case 1:
+#ifndef QT_NO_MENU
+ if (toolButton()->menu())
+ return QToolButton::tr("Open");
+#endif
+ //fall through
+ case 2:
+ return QLatin1String("Set Focus");
+ }
+ }
+ return QString();
+}
+
+/*!
+ \internal
+*/
+bool QAccessibleToolButton::doAction(int action, int child, const QVariantList &params)
+{
+ if (!widget()->isEnabled() || !widget()->isVisible())
+ return false;
+ if (action == 1 || child == ButtonDropMenu) {
+ if(!child)
+ toolButton()->setDown(true);
+#ifndef QT_NO_MENU
+ toolButton()->showMenu();
+#endif
+ return true;
+ }
+ return QAccessibleButton::doAction(action, 0, params);
+}
+
+#endif // QT_NO_TOOLBUTTON
+
+/*!
+ \class QAccessibleDisplay
+ \brief The QAccessibleDisplay class implements the QAccessibleInterface for widgets that display information.
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ Constructs a QAccessibleDisplay object for \a w.
+ \a role is propagated to the QAccessibleWidgetEx constructor.
+*/
+QAccessibleDisplay::QAccessibleDisplay(QWidget *w, Role role)
+: QAccessibleWidgetEx(w, role)
+{
+}
+
+/*! \reimp */
+QAccessible::Role QAccessibleDisplay::role(int child) const
+{
+ QLabel *l = qobject_cast<QLabel*>(object());
+ if (l) {
+ if (l->pixmap())
+ return Graphic;
+#ifndef QT_NO_PICTURE
+ if (l->picture())
+ return Graphic;
+#endif
+#ifndef QT_NO_MOVIE
+ if (l->movie())
+ return Animation;
+#endif
+#ifndef QT_NO_PROGRESSBAR
+ } else if (qobject_cast<QProgressBar*>(object())) {
+ return ProgressBar;
+#endif
+ }
+ return QAccessibleWidgetEx::role(child);
+}
+
+/*! \reimp */
+QString QAccessibleDisplay::text(Text t, int child) const
+{
+ QString str;
+ if (!widget()->isVisible())
+ return str;
+ switch (t) {
+ case Name:
+ str = widget()->accessibleName();
+ if (str.isEmpty()) {
+ if (qobject_cast<QLabel*>(object())) {
+ str = qobject_cast<QLabel*>(object())->text();
+#ifndef QT_NO_GROUPBOX
+ } else if (qobject_cast<QGroupBox*>(object())) {
+ str = qobject_cast<QGroupBox*>(object())->title();
+#endif
+#ifndef QT_NO_LCDNUMBER
+ } else if (qobject_cast<QLCDNumber*>(object())) {
+ QLCDNumber *l = qobject_cast<QLCDNumber*>(object());
+ if (l->digitCount())
+ str = QString::number(l->value());
+ else
+ str = QString::number(l->intValue());
+#endif
+ }
+ }
+ break;
+ case Value:
+#ifndef QT_NO_PROGRESSBAR
+ if (qobject_cast<QProgressBar*>(object()))
+ str = QString::number(qobject_cast<QProgressBar*>(object())->value());
+#endif
+ break;
+ default:
+ break;
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, child);;
+ return qt_accStripAmp(str);
+}
+
+/*! \reimp */
+QAccessible::Relation QAccessibleDisplay::relationTo(int child, const QAccessibleInterface *other,
+ int otherChild) const
+{
+ Relation relation = QAccessibleWidgetEx::relationTo(child, other, otherChild);
+ if (child || otherChild)
+ return relation;
+
+ QObject *o = other->object();
+ QLabel *label = qobject_cast<QLabel*>(object());
+ if (label) {
+#ifndef QT_NO_SHORTCUT
+ if (o == label->buddy())
+ relation |= Label;
+#endif
+#ifndef QT_NO_GROUPBOX
+ } else {
+ QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
+ if (groupbox && !groupbox->title().isEmpty())
+ if (groupbox->children().contains(o))
+ relation |= Label;
+#endif
+ }
+ return relation;
+}
+
+/*! \reimp */
+int QAccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
+{
+ *target = 0;
+ if (rel == Labelled) {
+ QObject *targetObject = 0;
+ QLabel *label = qobject_cast<QLabel*>(object());
+ if (label) {
+#ifndef QT_NO_SHORTCUT
+ if (entry == 1)
+ targetObject = label->buddy();
+#endif
+#ifndef QT_NO_GROUPBOX
+ } else {
+ QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
+ if (groupbox && !groupbox->title().isEmpty())
+ rel = Child;
+#endif
+ }
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ if (*target)
+ return 0;
+ }
+ return QAccessibleWidgetEx::navigate(rel, entry, target);
+}
+
+/*! \internal */
+QString QAccessibleDisplay::imageDescription()
+{
+#ifndef QT_NO_TOOLTIP
+ return widget()->toolTip();
+#else
+ return QString::null;
+#endif
+}
+
+/*! \internal */
+QSize QAccessibleDisplay::imageSize()
+{
+ QLabel *label = qobject_cast<QLabel *>(widget());
+ if (!label)
+ return QSize();
+ const QPixmap *pixmap = label->pixmap();
+ if (!pixmap)
+ return QSize();
+ return pixmap->size();
+}
+
+/*! \internal */
+QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
+{
+ QLabel *label = qobject_cast<QLabel *>(widget());
+ if (!label)
+ return QRect();
+ const QPixmap *pixmap = label->pixmap();
+ if (!pixmap)
+ return QRect();
+
+ switch (coordType) {
+ case QAccessible2::RelativeToScreen:
+ return QRect(label->mapToGlobal(label->pos()), label->size());
+ case QAccessible2::RelativeToParent:
+ return label->geometry();
+ }
+
+ return QRect();
+}
+
+#ifndef QT_NO_LINEEDIT
+/*!
+ \class QAccessibleLineEdit
+ \brief The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text
+ \internal
+
+ \ingroup accessibility
+*/
+
+/*!
+ Constructs a QAccessibleLineEdit object for \a w.
+ \a name is propagated to the QAccessibleWidgetEx constructor.
+*/
+QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name)
+: QAccessibleWidgetEx(w, EditableText, name), QAccessibleSimpleEditableTextInterface(this)
+{
+ addControllingSignal(QLatin1String("textChanged(const QString&)"));
+ addControllingSignal(QLatin1String("returnPressed()"));
+}
+
+/*! Returns the line edit. */
+QLineEdit *QAccessibleLineEdit::lineEdit() const
+{
+ return qobject_cast<QLineEdit*>(object());
+}
+
+/*! \reimp */
+QString QAccessibleLineEdit::text(Text t, int child) const
+{
+ QString str;
+ if (!lineEdit()->isVisible())
+ return str;
+ switch (t) {
+ case Value:
+ if (lineEdit()->echoMode() == QLineEdit::Normal)
+ str = lineEdit()->text();
+ break;
+ default:
+ break;
+ }
+ if (str.isEmpty())
+ str = QAccessibleWidgetEx::text(t, child);;
+ return qt_accStripAmp(str);
+}
+
+/*! \reimp */
+void QAccessibleLineEdit::setText(Text t, int control, const QString &text)
+{
+ if (!lineEdit()->isVisible())
+ return;
+ if (t != Value || control) {
+ QAccessibleWidgetEx::setText(t, control, text);
+ return;
+ }
+ lineEdit()->setText(text);
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleLineEdit::state(int child) const
+{
+ State state = QAccessibleWidgetEx::state(child);
+
+ QLineEdit *l = lineEdit();
+ if (l->isReadOnly())
+ state |= ReadOnly;
+ if (l->echoMode() != QLineEdit::Normal)
+ state |= Protected;
+ state |= Selectable;
+ if (l->hasSelectedText())
+ state |= Selected;
+
+ if (l->contextMenuPolicy() != Qt::NoContextMenu
+ && l->contextMenuPolicy() != Qt::PreventContextMenu)
+ state |= HasPopup;
+
+ return state;
+}
+
+QVariant QAccessibleLineEdit::invokeMethodEx(QAccessible::Method method, int child,
+ const QVariantList &params)
+{
+ if (child)
+ return QVariant();
+
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods << SetCursorPosition << GetCursorPosition;
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
+ }
+ case SetCursorPosition:
+ setCursorPosition(params.value(0).toInt());
+ return true;
+ case GetCursorPosition:
+ return cursorPosition();
+ default:
+ return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
+ }
+}
+
+void QAccessibleLineEdit::addSelection(int startOffset, int endOffset)
+{
+ setSelection(0, startOffset, endOffset);
+}
+
+QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset)
+{
+ // QLineEdit doesn't have text attributes
+ *startOffset = *endOffset = offset;
+ return QString();
+}
+
+int QAccessibleLineEdit::cursorPosition()
+{
+ return lineEdit()->cursorPosition();
+}
+
+QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/)
+{
+ // QLineEdit doesn't hand out character rects
+ return QRect();
+}
+
+int QAccessibleLineEdit::selectionCount()
+{
+ return lineEdit()->hasSelectedText() ? 1 : 0;
+}
+
+int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType)
+{
+ QPoint p = point;
+ if (coordType == RelativeToScreen)
+ p = lineEdit()->mapFromGlobal(p);
+
+ return lineEdit()->cursorPositionAt(p);
+}
+
+void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset)
+{
+ *startOffset = *endOffset = 0;
+ if (selectionIndex != 0)
+ return;
+
+ *startOffset = lineEdit()->selectionStart();
+ *endOffset = *startOffset + lineEdit()->selectedText().count();
+}
+
+QString QAccessibleLineEdit::text(int startOffset, int endOffset)
+{
+ if (startOffset > endOffset)
+ return QString();
+ return lineEdit()->text().mid(startOffset, endOffset - startOffset);
+}
+
+QString QAccessibleLineEdit::textBeforeOffset (int /*offset*/, BoundaryType /*boundaryType*/,
+ int * /*startOffset*/, int * /*endOffset*/)
+{
+ // TODO
+ return QString();
+}
+
+QString QAccessibleLineEdit::textAfterOffset(int /*offset*/, BoundaryType /*boundaryType*/,
+ int * /*startOffset*/, int * /*endOffset*/)
+{
+ // TODO
+ return QString();
+}
+
+QString QAccessibleLineEdit::textAtOffset(int /*offset*/, BoundaryType /*boundaryType*/,
+ int * /*startOffset*/, int * /*endOffset*/)
+{
+ // TODO
+ return QString();
+}
+
+void QAccessibleLineEdit::removeSelection(int selectionIndex)
+{
+ if (selectionIndex != 0)
+ return;
+
+ lineEdit()->deselect();
+}
+
+void QAccessibleLineEdit::setCursorPosition(int position)
+{
+ lineEdit()->setCursorPosition(position);
+}
+
+void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int endOffset)
+{
+ if (selectionIndex != 0)
+ return;
+
+ lineEdit()->setSelection(startOffset, endOffset - startOffset);
+}
+
+int QAccessibleLineEdit::characterCount()
+{
+ return lineEdit()->text().count();
+}
+
+void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex)
+{
+ lineEdit()->setCursorPosition(endIndex);
+ lineEdit()->setCursorPosition(startIndex);
+}
+
+#endif // QT_NO_LINEEDIT
+
+#ifndef QT_NO_PROGRESSBAR
+QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o)
+ : QAccessibleDisplay(o)
+{
+ Q_ASSERT(progressBar());
+}
+
+QVariant QAccessibleProgressBar::currentValue()
+{
+ return progressBar()->value();
+}
+
+QVariant QAccessibleProgressBar::maximumValue()
+{
+ return progressBar()->maximum();
+}
+
+QVariant QAccessibleProgressBar::minimumValue()
+{
+ return progressBar()->minimum();
+}
+
+QProgressBar *QAccessibleProgressBar::progressBar() const
+{
+ return qobject_cast<QProgressBar *>(object());
+}
+#endif
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h
new file mode 100644
index 0000000000..ca1f24bfc2
--- /dev/null
+++ b/src/plugins/accessible/widgets/simplewidgets.h
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMPLEWIDGETS_H
+#define SIMPLEWIDGETS_H
+
+#include <QtCore/qcoreapplication.h>
+#include <QtGui/qaccessible2.h>
+#include <QtGui/qaccessiblewidget.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QAbstractButton;
+class QLineEdit;
+class QToolButton;
+class QProgressBar;
+
+class QAccessibleButton : public QAccessibleWidgetEx, public QAccessibleActionInterface
+{
+ Q_ACCESSIBLE_OBJECT
+ Q_DECLARE_TR_FUNCTIONS(QAccessibleButton)
+public:
+ QAccessibleButton(QWidget *w, Role r);
+
+ QString text(Text t, int child) const;
+ State state(int child) const;
+
+ QString actionText(int action, Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+
+ // QAccessibleActionInterface
+ int actionCount();
+ void doAction(int actionIndex);
+ QString description(int actionIndex);
+ QString name(int actionIndex);
+ QString localizedName(int actionIndex);
+ QStringList keyBindings(int actionIndex);
+
+protected:
+ QAbstractButton *button() const;
+};
+
+#ifndef QT_NO_TOOLBUTTON
+class QAccessibleToolButton : public QAccessibleButton
+{
+public:
+ QAccessibleToolButton(QWidget *w, Role role);
+
+ enum ToolButtonElements {
+ ToolButtonSelf = 0,
+ ButtonExecute,
+ ButtonDropMenu
+ };
+
+ Role role(int child) const;
+ State state(int child) const;
+
+ int childCount() const;
+ QRect rect(int child) const;
+
+ QString text(Text t, int child) const;
+
+ int actionCount(int child) const;
+ QString actionText(int action, Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+
+protected:
+ QToolButton *toolButton() const;
+
+ bool isSplitButton() const;
+};
+#endif // QT_NO_TOOLBUTTON
+
+class QAccessibleDisplay : public QAccessibleWidgetEx, public QAccessibleImageInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleDisplay(QWidget *w, Role role = StaticText);
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+ int navigate(RelationFlag, int entry, QAccessibleInterface **target) const;
+
+ // QAccessibleImageInterface
+ QString imageDescription();
+ QSize imageSize();
+ QRect imagePosition(QAccessible2::CoordinateType coordType);
+};
+
+#ifndef QT_NO_LINEEDIT
+class QAccessibleLineEdit : public QAccessibleWidgetEx, public QAccessibleTextInterface,
+ public QAccessibleSimpleEditableTextInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString());
+
+ QString text(Text t, int child) const;
+ void setText(Text t, int control, const QString &text);
+ State state(int child) const;
+ QVariant invokeMethodEx(QAccessible::Method method, int child, const QVariantList &params);
+
+ // QAccessibleTextInterface
+ void addSelection(int startOffset, int endOffset);
+ QString attributes(int offset, int *startOffset, int *endOffset);
+ int cursorPosition();
+ QRect characterRect(int offset, QAccessible2::CoordinateType coordType);
+ int selectionCount();
+ int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType);
+ void selection(int selectionIndex, int *startOffset, int *endOffset);
+ QString text(int startOffset, int endOffset);
+ QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset);
+ QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset);
+ QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset);
+ void removeSelection(int selectionIndex);
+ void setCursorPosition(int position);
+ void setSelection(int selectionIndex, int startOffset, int endOffset);
+ int characterCount();
+ void scrollToSubstring(int startIndex, int endIndex);
+
+protected:
+ QLineEdit *lineEdit() const;
+};
+#endif // QT_NO_LINEEDIT
+
+#ifndef QT_NO_PROGRESSBAR
+class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface
+{
+ Q_ACCESSIBLE_OBJECT
+public:
+ explicit QAccessibleProgressBar(QWidget *o);
+
+ // QAccessibleValueInterface
+ QVariant currentValue();
+ QVariant maximumValue();
+ QVariant minimumValue();
+ inline void setCurrentValue(const QVariant &) {}
+
+protected:
+ QProgressBar *progressBar() const;
+};
+#endif
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+#endif // SIMPLEWIDGETS_H
diff --git a/src/plugins/accessible/widgets/widgets.pro b/src/plugins/accessible/widgets/widgets.pro
new file mode 100644
index 0000000000..79110cbcd4
--- /dev/null
+++ b/src/plugins/accessible/widgets/widgets.pro
@@ -0,0 +1,20 @@
+TARGET = qtaccessiblewidgets
+include(../../qpluginbase.pri)
+include (../qaccessiblebase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/accessible
+
+QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)"
+
+SOURCES += main.cpp \
+ simplewidgets.cpp \
+ rangecontrols.cpp \
+ complexwidgets.cpp \
+ qaccessiblewidgets.cpp \
+ qaccessiblemenu.cpp
+
+HEADERS += qaccessiblewidgets.h \
+ simplewidgets.h \
+ rangecontrols.h \
+ complexwidgets.h \
+ qaccessiblemenu.h
diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro
new file mode 100644
index 0000000000..d1d75f06fb
--- /dev/null
+++ b/src/plugins/bearer/bearer.pro
@@ -0,0 +1,19 @@
+TEMPLATE = subdirs
+
+contains(QT_CONFIG, dbus) {
+ contains(QT_CONFIG, icd) {
+ SUBDIRS += icd
+ } else:linux* {
+ SUBDIRS += generic
+ SUBDIRS += connman networkmanager
+ }
+}
+
+#win32:SUBDIRS += nla
+win32:SUBDIRS += generic
+win32:!wince*:SUBDIRS += nativewifi
+macx:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan
+macx:SUBDIRS += generic
+symbian:SUBDIRS += symbian
+
+isEmpty(SUBDIRS):SUBDIRS = generic
diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro
new file mode 100644
index 0000000000..dec408c724
--- /dev/null
+++ b/src/plugins/bearer/connman/connman.pro
@@ -0,0 +1,21 @@
+TARGET = qconnmanbearer
+include(../../qpluginbase.pri)
+
+QT = core network dbus
+
+HEADERS += qconnmanservice_linux_p.h \
+ qofonoservice_linux_p.h \
+ qconnmanengine.h \
+ ../qnetworksession_impl.h \
+ ../qbearerengine_impl.h
+
+SOURCES += main.cpp \
+ qconnmanservice_linux.cpp \
+ qofonoservice_linux.cpp \
+ qconnmanengine.cpp \
+ ../qnetworksession_impl.cpp
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
+target.path += $$[QT_INSTALL_PLUGINS]/bearer
+INSTALLS += target
+
diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp
new file mode 100644
index 0000000000..681b871479
--- /dev/null
+++ b/src/plugins/bearer/connman/main.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qconnmanengine.h"
+
+#include <QtNetwork/private/qbearerplugin_p.h>
+
+#include <QtCore/qdebug.h>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+class QConnmanEnginePlugin : public QBearerEnginePlugin
+{
+public:
+ QConnmanEnginePlugin();
+ ~QConnmanEnginePlugin();
+
+ QStringList keys() const;
+ QBearerEngine *create(const QString &key) const;
+};
+
+QConnmanEnginePlugin::QConnmanEnginePlugin()
+{
+}
+
+QConnmanEnginePlugin::~QConnmanEnginePlugin()
+{
+}
+
+QStringList QConnmanEnginePlugin::keys() const
+{
+ return QStringList() << QLatin1String("connman");
+}
+
+QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const
+{
+ if (key == QLatin1String("connman")) {
+ QConnmanEngine *engine = new QConnmanEngine;
+ if (engine->connmanAvailable())
+ return engine;
+ else
+ delete engine;
+ }
+ return 0;
+}
+
+Q_EXPORT_STATIC_PLUGIN(QConnmanEnginePlugin)
+Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin)
+
+QT_END_NAMESPACE
+
+#endif
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
new file mode 100644
index 0000000000..53c9a7d431
--- /dev/null
+++ b/src/plugins/bearer/connman/qconnmanengine.cpp
@@ -0,0 +1,594 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qconnmanengine.h"
+#include "qconnmanservice_linux_p.h"
+#include "qofonoservice_linux_p.h"
+#include "../qnetworksession_impl.h"
+
+#include <QtNetwork/private/qnetworkconfiguration_p.h>
+
+#include <QtNetwork/qnetworksession.h>
+
+#include <QtCore/qdebug.h>
+
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+QConnmanEngine::QConnmanEngine(QObject *parent)
+: QBearerEngineImpl(parent),
+ connmanManager(new QConnmanManagerInterface(this))
+{
+}
+
+QConnmanEngine::~QConnmanEngine()
+{
+}
+
+bool QConnmanEngine::connmanAvailable() const
+{
+ QMutexLocker locker(&mutex);
+ return connmanManager->isValid();
+}
+
+void QConnmanEngine::initialize()
+{
+ connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(propertyChangedContext(QString,QString,QDBusVariant)));
+
+ foreach(const QString techPath, connmanManager->getTechnologies()) {
+ QConnmanTechnologyInterface *tech;
+ tech = new QConnmanTechnologyInterface(techPath, this);
+
+ connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
+ }
+
+ foreach(const QString servPath, connmanManager->getServices()) {
+ addServiceConfiguration(servPath);
+ }
+
+ // Get current list of access points.
+ getConfigurations();
+}
+
+QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
+{
+ QMutexLocker locker(&mutex);
+ QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
+ QNetworkConfigurationPrivate* cpPriv = 0;
+
+ for (int i = 0; i < foundConfigurations.count(); ++i) {
+ QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
+ cpPriv = foundConfigurations.at(i);
+
+ config->name = cpPriv->name;
+ config->isValid = cpPriv->isValid;
+ config->id = cpPriv->id;
+ config->state = cpPriv->state;
+ config->type = cpPriv->type;
+ config->roamingSupported = cpPriv->roamingSupported;
+ config->purpose = cpPriv->purpose;
+ config->bearerType = cpPriv->bearerType;
+
+ fetchedConfigurations.append(config);
+ delete config;
+ }
+ return fetchedConfigurations;
+}
+
+void QConnmanEngine::doRequestUpdate()
+{
+ connmanManager->requestScan("");
+ getConfigurations();
+ emit updateCompleted();
+}
+
+QString QConnmanEngine::getInterfaceFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ return configInterfaces.value(id);
+}
+
+bool QConnmanEngine::hasIdentifier(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ return accessPointConfigurations.contains(id);
+}
+
+void QConnmanEngine::connectToId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ QString servicePath = serviceFromId(id);
+ QConnmanServiceInterface serv(servicePath);
+ if(!serv.isValid()) {
+ emit connectionError(id, QBearerEngineImpl::InterfaceLookupError);
+ } else {
+ if(serv.getType() != "cellular") {
+
+ serv.connect();
+ } else {
+ QOfonoManagerInterface ofonoManager(0);
+ QString modemPath = ofonoManager.currentModem().path();
+ QOfonoDataConnectionManagerInterface dc(modemPath,0);
+ foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
+ if(dcPath.path().contains(servicePath.section("_",-1))) {
+ QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
+ primaryContext.setActive(true);
+ }
+ }
+ }
+ }
+}
+
+void QConnmanEngine::disconnectFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ QString servicePath = serviceFromId(id);
+ QConnmanServiceInterface serv(servicePath);
+ if(!serv.isValid()) {
+ emit connectionError(id, DisconnectionError);
+ } else {
+ if(serv.getType() != "cellular") {
+ serv.disconnect();
+ } else {
+ QOfonoManagerInterface ofonoManager(0);
+ QString modemPath = ofonoManager.currentModem().path();
+ QOfonoDataConnectionManagerInterface dc(modemPath,0);
+ foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
+ if(dcPath.path().contains(servicePath.section("_",-1))) {
+ QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
+ primaryContext.setActive(false);
+ }
+ }
+ }
+ }
+}
+
+void QConnmanEngine::requestUpdate()
+{
+ QMutexLocker locker(&mutex);
+ QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
+}
+
+QString QConnmanEngine::serviceFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ foreach(const QString service, serviceNetworks) {
+ if (id == QString::number(qHash(service)))
+ return service;
+ }
+
+ return QString();
+}
+
+QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ if (!ptr)
+ return QNetworkSession::Invalid;
+
+ if (!ptr->isValid) {
+ return QNetworkSession::Invalid;
+
+ }
+ QString service = serviceFromId(id);
+ QConnmanServiceInterface serv(service);
+ QString servState = serv.getState();
+
+ if(serv.isFavorite() && (servState == "idle" || servState == "failure")) {
+ return QNetworkSession::Disconnected;
+ }
+
+ if(servState == "association" || servState == "configuration" || servState == "login") {
+ return QNetworkSession::Connecting;
+ }
+ if(servState == "ready" || servState == "online") {
+ return QNetworkSession::Connected;
+ }
+
+ if ((ptr->state & QNetworkConfiguration::Discovered) ==
+ QNetworkConfiguration::Discovered) {
+ return QNetworkSession::Disconnected;
+ } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
+ return QNetworkSession::NotAvailable;
+ } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
+ QNetworkConfiguration::Undefined) {
+ return QNetworkSession::NotAvailable;
+ }
+
+ return QNetworkSession::Invalid;
+}
+
+quint64 QConnmanEngine::bytesWritten(const QString &id)
+{//TODO use connman counter API
+ QMutexLocker locker(&mutex);
+ quint64 result = 0;
+ QString devFile = getInterfaceFromId(id);
+ QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
+ if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&tx);
+ in >> result;
+ tx.close();
+ }
+
+ return result;
+}
+
+quint64 QConnmanEngine::bytesReceived(const QString &id)
+{//TODO use connman counter API
+ QMutexLocker locker(&mutex);
+ quint64 result = 0;
+ QString devFile = getInterfaceFromId(id);
+ QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
+ if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&rx);
+ in >> result;
+ rx.close();
+ }
+ return result;
+}
+
+quint64 QConnmanEngine::startTime(const QString &/*id*/)
+{
+ // TODO
+ QMutexLocker locker(&mutex);
+ if (activeTime.isNull()) {
+ return 0;
+ }
+ return activeTime.secsTo(QDateTime::currentDateTime());
+}
+
+QNetworkConfigurationManager::Capabilities QConnmanEngine::capabilities() const
+{
+ return QNetworkConfigurationManager::ForcedRoaming |
+ QNetworkConfigurationManager::DataStatistics |
+ QNetworkConfigurationManager::CanStartAndStopInterfaces;
+}
+
+QNetworkSessionPrivate *QConnmanEngine::createSessionBackend()
+{
+ return new QNetworkSessionPrivateImpl;
+}
+
+QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration()
+{
+ return QNetworkConfigurationPrivatePointer();
+}
+
+void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value)
+{
+ Q_UNUSED(path);
+
+ QMutexLocker locker(&mutex);
+ if(item == "Services") {
+ QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant());
+ QStringList list = qdbus_cast<QStringList>(arg);
+
+ if(list.count() > accessPointConfigurations.count()) {
+ foreach(const QString service, list) {
+ addServiceConfiguration(service);
+ }
+ }
+ }
+
+ if(item == "Technologies") {
+ QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant());
+ QStringList newlist = qdbus_cast<QStringList>(arg);
+ if(newlist.count() > 0) {
+ QMap<QString,QConnmanTechnologyInterface *> oldtech = technologies;
+
+ foreach(const QString listPath, newlist) {
+ if(!oldtech.contains(listPath)) {
+ QConnmanTechnologyInterface *tech;
+ tech = new QConnmanTechnologyInterface(listPath,this);
+ connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
+ technologies.insert(listPath, tech);
+ }
+ }
+ }
+ }
+ if(item == "State") {
+// qDebug() << value.variant();
+ }
+}
+
+void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value)
+{
+ QMutexLocker locker(&mutex);
+ if(item == "State") {
+ configurationChange(QString::number(qHash(path)));
+
+ if(value.variant().toString() == "failure") {
+ QConnmanServiceInterface serv(path);
+ emit connectionError(QString::number(qHash(path)), ConnectError);
+ }
+ }
+}
+
+void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value)
+{
+ if(item == "State") {
+ if(value.variant().toString() == "offline") {
+ QConnmanTechnologyInterface tech(path);
+ disconnect(&tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
+
+ technologies.remove(path);
+ }
+ }
+}
+
+void QConnmanEngine::configurationChange(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ if (accessPointConfigurations.contains(id)) {
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ QString servicePath = serviceFromId(id);
+ QConnmanServiceInterface *serv;
+ serv = new QConnmanServiceInterface(servicePath);
+ QString networkName = serv->getName();
+
+ QNetworkConfiguration::StateFlags curState = getStateForService(servicePath);
+
+ ptr->mutex.lock();
+
+ if (!ptr->isValid) {
+ ptr->isValid = true;
+ }
+
+ if (ptr->name != networkName) {
+ ptr->name = networkName;
+ }
+
+ if (ptr->state != curState) {
+ ptr->state = curState;
+ }
+
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ }
+
+ locker.unlock();
+ emit updateCompleted();
+}
+
+QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service)
+{
+ QMutexLocker locker(&mutex);
+ QConnmanServiceInterface serv(service);
+ QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
+ if( serv.getType() == "cellular") {
+ if(serv.isSetupRequired()) {
+ flag = ( flag | QNetworkConfiguration::Defined);
+ } else {
+ flag = ( flag | QNetworkConfiguration::Discovered);
+ }
+ } else {
+ if(serv.isFavorite()) {
+ flag = ( flag | QNetworkConfiguration::Discovered);
+ } else {
+ flag = QNetworkConfiguration::Undefined;
+ }
+ }
+
+ if(serv.getState() == "ready" || serv.getState() == "online") {
+ flag = ( flag | QNetworkConfiguration::Active);
+ }
+
+ return flag;
+}
+
+QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &type)
+{
+ if (type == "wifi")
+ return QNetworkConfiguration::BearerWLAN;
+ if (type == "ethernet")
+ return QNetworkConfiguration::BearerEthernet;
+ if (type == "bluetooth")
+ return QNetworkConfiguration::BearerBluetooth;
+ if (type == "cellular") {
+ return ofonoTechToBearerType(type);
+ }
+ if (type == "wimax")
+ return QNetworkConfiguration::BearerWiMAX;
+
+// if(type == "gps")
+// if(type == "vpn")
+
+ return QNetworkConfiguration::BearerUnknown;
+}
+
+QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QString &/*type*/)
+{
+ QOfonoManagerInterface ofonoManager(this);
+ QOfonoNetworkRegistrationInterface ofonoNetwork(ofonoManager.currentModem().path(),this);
+
+ if(ofonoNetwork.isValid()) {
+ foreach(const QDBusObjectPath op,ofonoNetwork.getOperators() ) {
+ QOfonoNetworkOperatorInterface opIface(op.path(),this);
+
+ foreach(const QString opTech, opIface.getTechnologies()) {
+
+ if(opTech == "gsm") {
+ return QNetworkConfiguration::Bearer2G;
+ }
+ if(opTech == "edge"){
+ return QNetworkConfiguration::BearerCDMA2000; //wrong, I know
+ }
+ if(opTech == "umts"){
+ return QNetworkConfiguration::BearerWCDMA;
+ }
+ if(opTech == "hspa"){
+ return QNetworkConfiguration::BearerHSPA;
+ }
+ if(opTech == "lte"){
+ return QNetworkConfiguration::BearerWiMAX; //not exact
+ }
+ }
+ }
+ }
+ return QNetworkConfiguration::BearerUnknown;
+}
+
+bool QConnmanEngine::isRoamingAllowed(const QString &context)
+{
+ QOfonoManagerInterface ofonoManager(this);
+ QString modemPath = ofonoManager.currentModem().path();
+ QOfonoDataConnectionManagerInterface dc(modemPath,this);
+ foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
+ if(dcPath.path().contains(context.section("_",-1))) {
+ return dc.isRoamingAllowed();
+ }
+ }
+ return false;
+}
+
+void QConnmanEngine::removeConfiguration(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ if (accessPointConfigurations.contains(id)) {
+
+ QString service = serviceFromId(id);
+ QConnmanServiceInterface serv(service);
+
+ disconnect(&serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant)));
+
+ serviceNetworks.removeOne(service);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
+ locker.unlock();
+ emit configurationRemoved(ptr);
+ locker.relock();
+ }
+}
+
+void QConnmanEngine::addServiceConfiguration(const QString &servicePath)
+{
+ QMutexLocker locker(&mutex);
+ QConnmanServiceInterface *serv;
+ serv = new QConnmanServiceInterface(servicePath);
+
+ const QString id = QString::number(qHash(servicePath));
+
+ if (!accessPointConfigurations.contains(id)) {
+ serviceNetworks.append(servicePath);
+
+ connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
+ this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant)));
+ QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
+
+ QString networkName = serv->getName();
+
+ const QString connectionType = serv->getType();
+ if (connectionType == "ethernet") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
+ } else if (connectionType == "wifi") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
+ } else if (connectionType == "cellular") {
+ cpPriv->bearerType = ofonoTechToBearerType("cellular");
+ if(servicePath.isEmpty()) {
+ networkName = serv->getAPN();
+ if(networkName.isEmpty()) {
+ networkName = serv->getName();
+ }
+ }
+ cpPriv->roamingSupported = isRoamingAllowed(servicePath);
+ } else if (connectionType == "wimax") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerWiMAX;
+ } else {
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
+ }
+
+ cpPriv->name = networkName;
+ cpPriv->isValid = true;
+ cpPriv->id = id;
+ cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
+
+ if(serv->getSecurity() == "none") {
+ cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
+ } else {
+ cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
+ }
+
+ cpPriv->state = getStateForService(servicePath);
+
+ QNetworkConfigurationPrivatePointer ptr(cpPriv);
+ accessPointConfigurations.insert(ptr->id, ptr);
+ foundConfigurations.append(cpPriv);
+ configInterfaces[cpPriv->id] = serv->getInterface();
+
+ locker.unlock();
+ emit configurationAdded(ptr);
+ locker.relock();
+ emit updateCompleted();
+ }
+}
+
+bool QConnmanEngine::requiresPolling() const
+{
+ return false;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h
new file mode 100644
index 0000000000..8219c126c1
--- /dev/null
+++ b/src/plugins/bearer/connman/qconnmanengine.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCONNMANENGINE_P_H
+#define QCONNMANENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "../qbearerengine_impl.h"
+
+#include "qconnmanservice_linux_p.h"
+
+#include <QMap>
+#include <QVariant>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+class QConnmanEngine : public QBearerEngineImpl
+{
+ Q_OBJECT
+
+public:
+ QConnmanEngine(QObject *parent = 0);
+ ~QConnmanEngine();
+
+ bool connmanAvailable() const;
+
+ virtual QString getInterfaceFromId(const QString &id);
+ bool hasIdentifier(const QString &id);
+
+ virtual void connectToId(const QString &id);
+ virtual void disconnectFromId(const QString &id);
+
+ Q_INVOKABLE void initialize();
+ Q_INVOKABLE void requestUpdate();
+
+ QNetworkSession::State sessionStateForId(const QString &id);
+ QNetworkSessionPrivate *createSessionBackend();
+
+ virtual quint64 bytesWritten(const QString &id);
+ virtual quint64 bytesReceived(const QString &id);
+ virtual quint64 startTime(const QString &id);
+
+
+ virtual QNetworkConfigurationManager::Capabilities capabilities() const;
+ virtual QNetworkConfigurationPrivatePointer defaultConfiguration();
+
+ void configurationChange(const QString &id);
+ QList<QNetworkConfigurationPrivate *> getConfigurations();
+
+
+private Q_SLOTS:
+
+ void doRequestUpdate();
+ void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+ void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &);
+
+private:
+ QConnmanManagerInterface *connmanManager;
+
+ QList<QNetworkConfigurationPrivate *> foundConfigurations;
+
+ QString serviceFromId(const QString &id);
+ QString networkFromId(const QString &id);
+
+ QNetworkConfiguration::StateFlags getStateForService(const QString &service);
+ QNetworkConfiguration::BearerType typeToBearer(const QString &type);
+
+ void removeConfiguration(const QString &servicePath);
+ void addServiceConfiguration(const QString &servicePath);
+ QDateTime activeTime;
+
+
+ QMap<QString,QConnmanTechnologyInterface *> technologies; // techpath, tech interface
+ QMap<QString,QString> configInterfaces; // id, interface name
+ QList<QString> serviceNetworks; //servpath
+
+ QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type);
+ bool isRoamingAllowed(const QString &context);
+protected:
+ bool requiresPolling() const;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif
+
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
new file mode 100644
index 0000000000..02b5eb9661
--- /dev/null
+++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
@@ -0,0 +1,894 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include <QList>
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusPendingCall>
+
+#include "qconnmanservice_linux_p.h"
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+static QDBusConnection dbusConnection = QDBusConnection::systemBus();
+
+
+QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
+ QLatin1String(CONNMAN_MANAGER_PATH),
+ CONNMAN_MANAGER_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QConnmanManagerInterface::~QConnmanManagerInterface()
+{
+}
+
+void QConnmanManagerInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(CONNMAN_SERVICE),
+ QLatin1String(CONNMAN_MANAGER_PATH),
+ QLatin1String(CONNMAN_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(stateChanged(QString))) {
+ if (!connection().connect(QLatin1String(CONNMAN_SERVICE),
+ QLatin1String(CONNMAN_MANAGER_PATH),
+ QLatin1String(CONNMAN_MANAGER_INTERFACE),
+ QLatin1String("StateChanged"),
+ this,SIGNAL(stateChanged(const QString&)))) {
+ qWarning() << "StateChanged not connected";
+
+ }
+ }
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QConnmanDBusHelper *helper;
+ helper = new QConnmanDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+ QLatin1String(CONNMAN_MANAGER_PATH),
+ QLatin1String(CONNMAN_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QConnmanManagerInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QConnmanManagerInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QConnmanManagerInterface::getProperties()
+{
+ if(this->isValid()) {
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+ } else return QVariantMap();
+}
+
+QString QConnmanManagerInterface::getState()
+{
+ QDBusReply<QString > reply = this->call("GetState");
+ return reply.value();
+}
+
+bool QConnmanManagerInterface::setProperty(const QString &name, const QDBusVariant &value)
+{
+ Q_UNUSED(name);
+ Q_UNUSED(value);
+ return false;
+}
+
+QDBusObjectPath QConnmanManagerInterface::createProfile(const QString &/*name*/)
+{
+ return QDBusObjectPath();
+}
+
+bool QConnmanManagerInterface::removeProfile(QDBusObjectPath /*path*/)
+{
+ return false;
+}
+
+bool QConnmanManagerInterface::requestScan(const QString &type)
+{
+ QDBusReply<QString> reply = this->call(QLatin1String("RequestScan"), QVariant::fromValue(type));
+
+ bool ok = true;
+ if(reply.error().type() == QDBusError::InvalidArgs) {
+ qWarning() << reply.error().message();
+ ok = false;
+ }
+ return ok;
+}
+
+bool QConnmanManagerInterface::enableTechnology(const QString &type)
+{
+ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("EnableTechnology"), QVariant::fromValue(type));
+ bool ok = true;
+ if(reply.error().type() == QDBusError::InvalidArgs) {
+ qWarning() << reply.error().message();
+ ok = false;
+ }
+ return ok;
+}
+
+bool QConnmanManagerInterface::disableTechnology(const QString &type)
+{
+ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("DisableTechnology"), QVariant::fromValue(type));
+ bool ok = true;
+ if(reply.error().type() == QDBusError::InvalidArgs) {
+ qWarning() << reply.error().message();
+ ok = false;
+ }
+ return ok;
+}
+
+QDBusObjectPath QConnmanManagerInterface::connectService(QVariantMap &map)
+{
+ QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("ConnectService"), QVariant::fromValue(map));
+ if(!reply.isValid()) {
+ qDebug() << reply.error().message();
+
+ }
+ return reply;
+}
+
+void QConnmanManagerInterface::registerAgent(QDBusObjectPath &/*path*/)
+{
+}
+
+void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/)
+{
+}
+
+void QConnmanManagerInterface::registerCounter(const QString &path, quint32 interval)
+{ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RegisterCounter"),
+ QVariant::fromValue(path),
+ QVariant::fromValue(interval));
+ if(reply.error().type() == QDBusError::InvalidArgs) {
+ qWarning() << reply.error().message();
+ }
+}
+
+void QConnmanManagerInterface::unregisterCounter(const QString &path)
+{ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("UnregisterCounter"),
+ QVariant::fromValue(path));
+ if(reply.error().type() == QDBusError::InvalidArgs) {
+ qWarning() << reply.error().message();
+ }
+}
+
+QString QConnmanManagerInterface::requestSession(const QString &bearerName)
+{
+ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RequestSession"),
+ QVariant::fromValue(bearerName));
+ return QString();
+}
+
+void QConnmanManagerInterface::releaseSession()
+{
+ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("ReleaseSession"));
+}
+
+
+QDBusObjectPath QConnmanManagerInterface::lookupService(const QString &service)
+{
+ QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("LookupService"), QVariant::fromValue(service));
+ if(!reply.isValid()) {
+ qDebug() << reply.error().message();
+ }
+ return reply;
+}
+
+// properties
+
+QStringList QConnmanManagerInterface::getAvailableTechnologies()
+{
+ QVariant var = getProperty("AvailableTechnologies");
+ return qdbus_cast<QStringList>(var);
+}
+
+QStringList QConnmanManagerInterface::getEnabledTechnologies()
+{
+ QVariant var = getProperty("EnabledTechnologies");
+ return qdbus_cast<QStringList>(var);
+}
+
+QStringList QConnmanManagerInterface::getConnectedTechnologies()
+{
+ QVariant var = getProperty("ConnectedTechnologies");
+ return qdbus_cast<QStringList>(var);
+}
+
+QString QConnmanManagerInterface::getDefaultTechnology()
+{
+ QVariant var = getProperty("DefaultTechnology");
+ return qdbus_cast<QString>(var);
+}
+
+bool QConnmanManagerInterface::getOfflineMode()
+{
+ QVariant var = getProperty("OfflineMode");
+ return qdbus_cast<bool>(var);
+}
+
+QString QConnmanManagerInterface::getActiveProfile()
+{
+ QVariant var = getProperty("ActiveProfile");
+ return qdbus_cast<QString>(var);
+}
+
+QStringList QConnmanManagerInterface::getProfiles()
+{
+ QVariant var = getProperty("Profiles");
+ return qdbus_cast<QStringList>(var);
+}
+
+QStringList QConnmanManagerInterface::getTechnologies()
+{
+ QVariant var = getProperty("Technologies");
+ return qdbus_cast<QStringList >(var);
+}
+
+QStringList QConnmanManagerInterface::getServices()
+{
+ QVariant var = getProperty("Services");
+ return qdbus_cast<QStringList >(var);
+}
+
+QString QConnmanManagerInterface::getPathForTechnology(const QString &name)
+{
+ foreach(const QString path, getTechnologies()) {
+ if(path.contains(name)) {
+ return path;
+ }
+ }
+ return "";
+}
+
+
+//////////////////////////
+QConnmanProfileInterface::QConnmanProfileInterface(const QString &dbusPathName,QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
+ dbusPathName,
+ CONNMAN_PROFILE_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QConnmanProfileInterface::~QConnmanProfileInterface()
+{
+}
+
+void QConnmanProfileInterface::connectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+ this->path(),
+ QLatin1String(CONNMAN_PROFILE_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(QString,QDBusVariant)));
+ }
+}
+
+void QConnmanProfileInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QVariant))) {
+
+ }
+}
+
+QVariantMap QConnmanProfileInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+QVariant QConnmanProfileInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ }
+ return var;
+}
+
+// properties
+QString QConnmanProfileInterface::getName()
+{
+
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+bool QConnmanProfileInterface::isOfflineMode()
+{
+ QVariant var = getProperty("OfflineMode");
+ return qdbus_cast<bool>(var);
+}
+
+QStringList QConnmanProfileInterface::getServices()
+{
+ QVariant var = getProperty("Services");
+ return qdbus_cast<QStringList>(var);
+}
+
+
+///////////////////////////
+QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
+ dbusPathName,
+ CONNMAN_SERVICE_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QConnmanServiceInterface::~QConnmanServiceInterface()
+{
+}
+
+void QConnmanServiceInterface::connectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+ this->path(),
+ QLatin1String(CONNMAN_SERVICE_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(QString,QDBusVariant)));
+ }
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QConnmanDBusHelper *helper;
+ helper = new QConnmanDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+ this->path(),
+ QLatin1String(CONNMAN_SERVICE_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QConnmanServiceInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariantMap QConnmanServiceInterface::getProperties()
+{
+ if(this->isValid()) {
+ QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+ }
+ else
+ return QVariantMap();
+}
+
+QVariant QConnmanServiceInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ }
+ return var;
+}
+
+void QConnmanServiceInterface::connect()
+{
+ this->asyncCall(QLatin1String("Connect"));
+}
+
+void QConnmanServiceInterface::disconnect()
+{
+ QDBusReply<QVariantMap> reply = this->call(QLatin1String("Disconnect"));
+}
+
+void QConnmanServiceInterface::remove()
+{
+ QDBusReply<QVariantMap> reply = this->call(QLatin1String("Remove"));
+}
+
+// void moveBefore(QDBusObjectPath &service);
+// void moveAfter(QDBusObjectPath &service);
+
+// properties
+QString QConnmanServiceInterface::getState()
+{
+ QVariant var = getProperty("State");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getError()
+{
+ QVariant var = getProperty("Error");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getName()
+{
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getType()
+{
+ QVariant var = getProperty("Type");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getMode()
+{
+ QVariant var = getProperty("Mode");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getSecurity()
+{
+ QVariant var = getProperty("Security");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getPassphrase()
+{
+ QVariant var = getProperty("Passphrase");
+ return qdbus_cast<QString>(var);
+}
+
+bool QConnmanServiceInterface::isPassphraseRequired()
+{
+ QVariant var = getProperty("PassphraseRequired");
+ return qdbus_cast<bool>(var);
+}
+
+quint8 QConnmanServiceInterface::getSignalStrength()
+{
+ QVariant var = getProperty("Strength");
+ return qdbus_cast<quint8>(var);
+}
+
+bool QConnmanServiceInterface::isFavorite()
+{
+ QVariant var = getProperty("Favorite");
+ return qdbus_cast<bool>(var);
+}
+
+bool QConnmanServiceInterface::isImmutable()
+{
+ QVariant var = getProperty("Immutable");
+ return qdbus_cast<bool>(var);
+}
+
+bool QConnmanServiceInterface::isAutoConnect()
+{
+ QVariant var = getProperty("AutoConnect");
+ return qdbus_cast<bool>(var);
+}
+
+bool QConnmanServiceInterface::isSetupRequired()
+{
+ QVariant var = getProperty("SetupRequired");
+ return qdbus_cast<bool>(var);
+}
+
+QString QConnmanServiceInterface::getAPN()
+{
+ QVariant var = getProperty("APN");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getMCC()
+{
+ QVariant var = getProperty("MCC");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanServiceInterface::getMNC()
+{
+ QVariant var = getProperty("MNC");
+ return qdbus_cast<QString>(var);
+}
+
+bool QConnmanServiceInterface::isRoaming()
+{
+ QVariant var = getProperty("Roaming");
+ return qdbus_cast<bool>(var);
+}
+
+QStringList QConnmanServiceInterface::getNameservers()
+{
+ QVariant var = getProperty("NameServers");
+ return qdbus_cast<QStringList>(var);
+}
+
+QStringList QConnmanServiceInterface::getDomains()
+{
+ QVariant var = getProperty("Domains");
+ return qdbus_cast<QStringList>(var);
+}
+
+QVariantMap QConnmanServiceInterface::getIPv4()
+{
+ QVariant var = getProperty("IPv4");
+ return qdbus_cast<QVariantMap >(var);
+}
+
+QVariantMap QConnmanServiceInterface::getIPv4Configuration()
+{
+ QVariant var = getProperty("IPv4.Configuration");
+ return qdbus_cast<QVariantMap >(var);
+}
+
+QVariantMap QConnmanServiceInterface::getProxy()
+{
+ QVariant var = getProperty("Proxy");
+ return qdbus_cast<QVariantMap >(var);
+}
+
+QVariantMap QConnmanServiceInterface::getEthernet()
+{
+ QVariant var = getProperty("Ethernet");
+ return qdbus_cast<QVariantMap >(var);
+}
+
+QString QConnmanServiceInterface::getMethod()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Method") {
+ return it.value().toString();
+ }
+ }
+ return QString();
+}
+
+QString QConnmanServiceInterface::getInterface()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Interface") {
+ return it.value().toString();
+ }
+ }
+
+ return QString();
+}
+
+QString QConnmanServiceInterface::getMacAddress()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Address") {
+ return it.value().toString();
+ }
+ }
+ return QString();
+}
+
+quint16 QConnmanServiceInterface::getMtu()
+{
+ quint16 mtu=0;
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "MTU") {
+ return it.value().toUInt();
+ }
+ }
+ return mtu;
+}
+
+quint16 QConnmanServiceInterface::getSpeed()
+{
+ quint16 speed=0;
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Speed") {
+ return it.value().toUInt();
+ }
+ }
+ return speed;
+}
+
+QString QConnmanServiceInterface::getDuplex()
+{
+ QVariant var;
+ QVariantMap map = getEthernet();
+
+ QMapIterator<QString,QVariant> it(map);
+ while(it.hasNext()) {
+ it.next();
+ if(it.key() == "Duplex") {
+ return it.value().toString();
+ }
+ }
+ return QString();
+}
+
+
+bool QConnmanServiceInterface::isOfflineMode()
+{
+ QVariant var = getProperty("OfflineMode");
+ return qdbus_cast<bool>(var);
+}
+
+QStringList QConnmanServiceInterface::getServices()
+{
+ QVariant var = getProperty("Services");
+ return qdbus_cast<QStringList>(var);
+}
+
+
+//////////////////////////
+QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
+ dbusPathName,
+ CONNMAN_TECHNOLOGY_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QConnmanTechnologyInterface::~QConnmanTechnologyInterface()
+{
+}
+
+void QConnmanTechnologyInterface::connectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+ this->path(),
+ QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(QString,QDBusVariant)));
+ }
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QConnmanDBusHelper *helper;
+ helper = new QConnmanDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+ this->path(),
+ QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QConnmanTechnologyInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariantMap QConnmanTechnologyInterface::getProperties()
+{
+ QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+QVariant QConnmanTechnologyInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ }
+ return var;
+}
+
+// properties
+QString QConnmanTechnologyInterface::getState()
+{
+ QVariant var = getProperty("State");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanTechnologyInterface::getName()
+{
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+QString QConnmanTechnologyInterface::getType()
+{
+ QVariant var = getProperty("Type");
+ return qdbus_cast<QString>(var);
+}
+
+
+//////////////////////////////////
+QConnmanAgentInterface::QConnmanAgentInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
+ dbusPathName,
+ CONNMAN_AGENT_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QConnmanAgentInterface::~QConnmanAgentInterface()
+{
+}
+
+void QConnmanAgentInterface::connectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+// dbusConnection.connect(QLatin1String(CONNMAN_SERVICE),
+// this->path(),
+// QLatin1String(CONNMAN_NETWORK_INTERFACE),
+// QLatin1String("PropertyChanged"),
+// this,SIGNAL(propertyChanged(const QString &, QVariant &)));
+ }
+}
+
+void QConnmanAgentInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QDBusVariant))) {
+
+ }
+}
+
+
+void QConnmanAgentInterface::release()
+{
+}
+
+void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QString &/*error*/)
+{
+}
+
+//dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields)
+//{
+//}
+
+void QConnmanAgentInterface::cancel()
+{
+}
+
+
+/////////////////////////////////////////
+QConnmanCounterInterface::QConnmanCounterInterface(const QString &dbusPathName,QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
+ dbusPathName,
+ CONNMAN_COUNTER_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QConnmanCounterInterface::~QConnmanCounterInterface()
+{
+}
+
+quint32 QConnmanCounterInterface::getReceivedByteCount()
+{
+ return 0;
+}
+
+quint32 QConnmanCounterInterface::getTransmittedByteCount()
+{
+ return 0;
+}
+
+quint64 QConnmanCounterInterface::getTimeOnline()
+{
+ return 0;
+}
+
+/////////////////////////////////////////
+QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent)
+ : QObject(parent)
+{
+}
+
+QConnmanDBusHelper::~QConnmanDBusHelper()
+{
+}
+
+void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
+{
+ QDBusMessage msg = this->message();
+ Q_EMIT propertyChangedContext(msg.path() ,item, var);
+}
+
+/////////////////
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
new file mode 100644
index 0000000000..d0ef6dc4f9
--- /dev/null
+++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
@@ -0,0 +1,323 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCONNMANSERVICE_H
+#define QCONNMANSERVICE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusContext>
+#include <QMap>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+#ifndef __CONNMAN_DBUS_H
+
+#define CONNMAN_SERVICE "net.connman"
+#define CONNMAN_PATH "/net/connman"
+
+#define CONNMAN_DEBUG_INTERFACE CONNMAN_SERVICE ".Debug"
+#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
+#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent"
+#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter"
+
+#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
+#define CONNMAN_MANAGER_PATH "/"
+
+#define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task"
+#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
+#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
+#define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider"
+#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+
+QT_BEGIN_NAMESPACE
+
+class QConnmanManagerInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QConnmanManagerInterface( QObject *parent = 0);
+ ~QConnmanManagerInterface();
+
+ QDBusObjectPath path() const;
+
+ QVariantMap getProperties();
+ bool setProperty(const QString &name, const QDBusVariant &value);
+ QDBusObjectPath createProfile(const QString &name);
+ bool removeProfile(QDBusObjectPath path);
+ bool requestScan(const QString &type);
+ bool enableTechnology(const QString &type);
+ bool disableTechnology(const QString &type);
+ QDBusObjectPath connectService(QVariantMap &map);
+ void registerAgent(QDBusObjectPath &path);
+ void unregisterAgent(QDBusObjectPath path);
+ void registerCounter(const QString &path, quint32 interval);
+ void unregisterCounter(const QString &path);
+
+ QString requestSession(const QString &bearerName);
+ void releaseSession();
+
+ // properties
+ QString getState();
+ QStringList getAvailableTechnologies();
+ QStringList getEnabledTechnologies();
+ QStringList getConnectedTechnologies();
+ QString getDefaultTechnology();
+ bool getOfflineMode();
+ QString getActiveProfile();
+ QStringList getProfiles();
+ QStringList getTechnologies();
+ QStringList getServices();
+ QDBusObjectPath lookupService(const QString &);
+
+ QString getPathForTechnology(const QString &tech);
+
+
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void stateChanged(const QString &);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+};
+
+class QConnmanProfileInterfacePrivate;
+class QConnmanProfileInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QConnmanProfileInterface(const QString &dbusPathName,QObject *parent = 0);
+ ~QConnmanProfileInterface();
+
+ QVariantMap getProperties();
+// properties
+ QString getName();
+ bool isOfflineMode();
+ QStringList getServices();
+
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+private:
+ QConnmanProfileInterfacePrivate *d;
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+};
+
+class QConnmanServiceInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = 0);
+ ~QConnmanServiceInterface();
+
+ QVariantMap getProperties();
+ // clearProperty
+ void connect();
+ void disconnect();
+ void remove();
+ // void moveBefore(QDBusObjectPath &service);
+ // void moveAfter(QDBusObjectPath &service);
+
+// properties
+ QString getState();
+ QString getError();
+ QString getName();
+ QString getType();
+ QString getMode();
+ QString getSecurity();
+ QString getPassphrase();
+ bool isPassphraseRequired();
+ quint8 getSignalStrength();
+ bool isFavorite();
+ bool isImmutable();
+ bool isAutoConnect();
+ bool isSetupRequired();
+ QString getAPN();
+ QString getMCC();
+ QString getMNC();
+ bool isRoaming();
+ QStringList getNameservers();
+ QStringList getDomains();
+ QVariantMap getIPv4();
+ QVariantMap getIPv4Configuration();
+ QVariantMap getProxy();
+ QVariantMap getEthernet();
+
+ QString getMethod();
+ QString getInterface();
+ QString getMacAddress();
+ quint16 getMtu();
+ quint16 getSpeed();
+ QString getDuplex();
+
+ bool isOfflineMode();
+ QStringList getServices();
+
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+};
+
+class QConnmanTechnologyInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = 0);
+ ~QConnmanTechnologyInterface();
+
+ QVariantMap getProperties();
+// properties
+ QString getState();
+ QString getName();
+ QString getType();
+
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+
+};
+
+class QConnmanAgentInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QConnmanAgentInterface(const QString &dbusPathName,QObject *parent = 0);
+ ~QConnmanAgentInterface();
+
+ void release();
+ void reportError(QDBusObjectPath &path, const QString &error);
+// dict requestInput(QDBusObjectPath &path, dict fields);
+ void cancel();
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+};
+
+class QConnmanCounterInterfacePrivate;
+class QConnmanCounterInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QConnmanCounterInterface(const QString &dbusPathName, QObject *parent = 0);
+ ~QConnmanCounterInterface();
+
+// void release();
+ QString getInterface();
+ quint32 getReceivedByteCount();
+ quint32 getTransmittedByteCount();
+ quint64 getTimeOnline();
+
+private:
+ QConnmanCounterInterfacePrivate *d;
+};
+
+class QConnmanDBusHelper: public QObject, protected QDBusContext
+ {
+ Q_OBJECT
+ public:
+ QConnmanDBusHelper(QObject *parent = 0);
+ ~QConnmanDBusHelper();
+
+ public slots:
+ void propertyChanged(const QString &, const QDBusVariant &);
+
+Q_SIGNALS:
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif //QCONNMANSERVICE_H
diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp
new file mode 100644
index 0000000000..e3fb2c6034
--- /dev/null
+++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp
@@ -0,0 +1,945 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QObject>
+#include <QList>
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusPendingCall>
+
+#include "qofonoservice_linux_p.h"
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+static QDBusConnection dbusConnection = QDBusConnection::systemBus();
+
+
+QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ QLatin1String(OFONO_MANAGER_PATH),
+ OFONO_MANAGER_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoManagerInterface::~QOfonoManagerInterface()
+{
+}
+
+QList <QDBusObjectPath> QOfonoManagerInterface::getModems()
+{
+ QVariant var = getProperty("Modems");
+ return qdbus_cast<QList<QDBusObjectPath> >(var);
+}
+
+QDBusObjectPath QOfonoManagerInterface::currentModem()
+{
+ QList<QDBusObjectPath> modems = getModems();
+ foreach(const QDBusObjectPath modem, modems) {
+ QOfonoModemInterface device(modem.path());
+ if(device.isPowered() && device.isOnline())
+ return modem;;
+ }
+ return QDBusObjectPath();
+}
+
+
+void QOfonoManagerInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ QLatin1String(OFONO_MANAGER_PATH),
+ QLatin1String(OFONO_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ QLatin1String(OFONO_MANAGER_PATH),
+ QLatin1String(OFONO_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ }
+}
+
+void QOfonoManagerInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoManagerInterface::getProperty(const QString &property)
+{
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ return map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return QVariant();
+}
+
+QVariantMap QOfonoManagerInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ if(reply.isValid())
+ return reply.value();
+ else
+ return QVariantMap();
+}
+
+QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent)
+ : QObject(parent)
+{
+}
+
+QOfonoDBusHelper::~QOfonoDBusHelper()
+{
+}
+
+void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
+{
+ QDBusMessage msg = this->message();
+ Q_EMIT propertyChangedContext(msg.path() ,item, var);
+}
+
+
+QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_MODEM_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoModemInterface::~QOfonoModemInterface()
+{
+}
+
+bool QOfonoModemInterface::isPowered()
+{
+ QVariant var = getProperty("Powered");
+ return qdbus_cast<bool>(var);
+}
+
+bool QOfonoModemInterface::isOnline()
+{
+ QVariant var = getProperty("Online");
+ return qdbus_cast<bool>(var);
+}
+
+QString QOfonoModemInterface::getName()
+{
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoModemInterface::getManufacturer()
+{
+ QVariant var = getProperty("Manufacturer");
+ return qdbus_cast<QString>(var);
+
+}
+
+QString QOfonoModemInterface::getModel()
+{
+
+ QVariant var = getProperty("Model");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoModemInterface::getRevision()
+{
+ QVariant var = getProperty("Revision");
+ return qdbus_cast<QString>(var);
+
+}
+QString QOfonoModemInterface::getSerial()
+{
+ QVariant var = getProperty("Serial");
+ return qdbus_cast<QString>(var);
+
+}
+
+QStringList QOfonoModemInterface::getFeatures()
+{
+ //sms, sim
+ QVariant var = getProperty("Features");
+ return qdbus_cast<QStringList>(var);
+}
+
+QStringList QOfonoModemInterface::getInterfaces()
+{
+ QVariant var = getProperty("Interfaces");
+ return qdbus_cast<QStringList>(var);
+}
+
+QString QOfonoModemInterface::defaultInterface()
+{
+ foreach(const QString &modem,getInterfaces()) {
+ return modem;
+ }
+ return QString();
+}
+
+
+void QOfonoModemInterface::connectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_MODEM_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_MODEM_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }}
+
+void QOfonoModemInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariantMap QOfonoModemInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+QVariant QOfonoModemInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+
+QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_NETWORK_REGISTRATION_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface()
+{
+}
+
+QString QOfonoNetworkRegistrationInterface::getStatus()
+{
+ /*
+ "unregistered" Not registered to any network
+ "registered" Registered to home network
+ "searching" Not registered, but searching
+ "denied" Registration has been denied
+ "unknown" Status is unknown
+ "roaming" Registered, but roaming*/
+ QVariant var = getProperty("Status");
+ return qdbus_cast<QString>(var);
+}
+
+quint16 QOfonoNetworkRegistrationInterface::getLac()
+{
+ QVariant var = getProperty("LocationAreaCode");
+ return var.value<quint16>();
+}
+
+
+quint32 QOfonoNetworkRegistrationInterface::getCellId()
+{
+ QVariant var = getProperty("CellId");
+ return var.value<quint32>();
+}
+
+QString QOfonoNetworkRegistrationInterface::getTechnology()
+{
+ // "gsm", "edge", "umts", "hspa","lte"
+ QVariant var = getProperty("Technology");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoNetworkRegistrationInterface::getOperatorName()
+{
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+int QOfonoNetworkRegistrationInterface::getSignalStrength()
+{
+ QVariant var = getProperty("Strength");
+ return qdbus_cast<int>(var);
+
+}
+
+QString QOfonoNetworkRegistrationInterface::getBaseStation()
+{
+ QVariant var = getProperty("BaseStation");
+ return qdbus_cast<QString>(var);
+}
+
+QList <QDBusObjectPath> QOfonoNetworkRegistrationInterface::getOperators()
+{
+ QVariant var = getProperty("Operators");
+ return qdbus_cast<QList <QDBusObjectPath> >(var);
+}
+
+void QOfonoNetworkRegistrationInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QOfonoNetworkRegistrationInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+
+
+QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_NETWORK_OPERATOR_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface()
+{
+}
+
+QString QOfonoNetworkOperatorInterface::getName()
+{
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoNetworkOperatorInterface::getStatus()
+{
+ // "unknown", "available", "current" and "forbidden"
+ QVariant var = getProperty("Status");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoNetworkOperatorInterface::getMcc()
+{
+ QVariant var = getProperty("MobileCountryCode");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoNetworkOperatorInterface::getMnc()
+{
+ QVariant var = getProperty("MobileNetworkCode");
+ return qdbus_cast<QString>(var);
+}
+
+QStringList QOfonoNetworkOperatorInterface::getTechnologies()
+{
+ QVariant var = getProperty("Technologies");
+ return qdbus_cast<QStringList>(var);
+}
+
+void QOfonoNetworkOperatorInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QOfonoNetworkOperatorInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QOfonoNetworkOperatorInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_SIM_MANAGER_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoSimInterface::~QOfonoSimInterface()
+{
+}
+
+bool QOfonoSimInterface::isPresent()
+{
+ QVariant var = getProperty("Present");
+ return qdbus_cast<bool>(var);
+}
+
+QString QOfonoSimInterface::getHomeMcc()
+{
+ QVariant var = getProperty("MobileCountryCode");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoSimInterface::getHomeMnc()
+{
+ QVariant var = getProperty("MobileNetworkCode");
+ return qdbus_cast<QString>(var);
+}
+
+// QStringList subscriberNumbers();
+// QMap<QString,QString> serviceNumbers();
+QString QOfonoSimInterface::pinRequired()
+{
+ QVariant var = getProperty("PinRequired");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoSimInterface::lockedPins()
+{
+ QVariant var = getProperty("LockedPins");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoSimInterface::cardIdentifier()
+{
+ QVariant var = getProperty("CardIdentifier");
+ return qdbus_cast<QString>(var);
+}
+
+void QOfonoSimInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QOfonoSimInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoSimInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QOfonoSimInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface()
+{
+}
+
+QList<QDBusObjectPath> QOfonoDataConnectionManagerInterface::getPrimaryContexts()
+{
+ QVariant var = getProperty("PrimaryContexts");
+ return qdbus_cast<QList<QDBusObjectPath> >(var);
+}
+
+bool QOfonoDataConnectionManagerInterface::isAttached()
+{
+ QVariant var = getProperty("Attached");
+ return qdbus_cast<bool>(var);
+}
+
+bool QOfonoDataConnectionManagerInterface::isRoamingAllowed()
+{
+ QVariant var = getProperty("RoamingAllowed");
+ return qdbus_cast<bool>(var);
+}
+
+bool QOfonoDataConnectionManagerInterface::isPowered()
+{
+ QVariant var = getProperty("Powered");
+ return qdbus_cast<bool>(var);
+}
+
+void QOfonoDataConnectionManagerInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QOfonoDataConnectionManagerInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_DATA_CONTEXT_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface()
+{
+}
+
+bool QOfonoPrimaryDataContextInterface::isActive()
+{
+ QVariant var = getProperty("Active");
+ return qdbus_cast<bool>(var);
+}
+
+QString QOfonoPrimaryDataContextInterface::getApName()
+{
+ QVariant var = getProperty("AccessPointName");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoPrimaryDataContextInterface::getType()
+{
+ QVariant var = getProperty("Type");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoPrimaryDataContextInterface::getName()
+{
+ QVariant var = getProperty("Name");
+ return qdbus_cast<QString>(var);
+}
+
+QVariantMap QOfonoPrimaryDataContextInterface::getSettings()
+{
+ QVariant var = getProperty("Settings");
+ return qdbus_cast<QVariantMap>(var);
+}
+
+QString QOfonoPrimaryDataContextInterface::getInterface()
+{
+ QVariant var = getProperty("Interface");
+ return qdbus_cast<QString>(var);
+}
+
+QString QOfonoPrimaryDataContextInterface::getAddress()
+{
+ QVariant var = getProperty("Address");
+ return qdbus_cast<QString>(var);
+}
+
+bool QOfonoPrimaryDataContextInterface::setActive(bool on)
+{
+// this->setProperty("Active", QVariant(on));
+
+ return setProp("Active", qVariantFromValue(on));
+}
+
+bool QOfonoPrimaryDataContextInterface::setApn(const QString &name)
+{
+ return setProp("AccessPointName", QVariant::fromValue(name));
+}
+
+void QOfonoPrimaryDataContextInterface::connectNotify(const char *signal)
+{
+if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
+ }
+}
+
+void QOfonoPrimaryDataContextInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QOfonoPrimaryDataContextInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var)
+{
+ QList<QVariant> args;
+ args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var));
+
+ QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,
+ QLatin1String("SetProperty"),
+ args);
+ bool ok = true;
+ if(reply.type() != QDBusMessage::ReplyMessage) {
+ qWarning() << reply.errorMessage();
+ ok = false;
+ }
+ qWarning() << reply.errorMessage();
+ return ok;
+}
+
+QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent)
+ : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
+ dbusPathName,
+ OFONO_SMS_MANAGER_INTERFACE,
+ QDBusConnection::systemBus(), parent)
+{
+}
+
+QOfonoSmsInterface::~QOfonoSmsInterface()
+{
+}
+
+void QOfonoSmsInterface::connectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
+ QOfonoDBusHelper *helper;
+ helper = new QOfonoDBusHelper(this);
+
+ dbusConnection.connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
+ QLatin1String("PropertyChanged"),
+ helper,SLOT(propertyChanged(QString,QDBusVariant)));
+
+
+ QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ }
+
+ if (QLatin1String(signal) == SIGNAL(immediateMessage(QString,QVariantMap))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
+ QLatin1String("ImmediateMessage"),
+ this,SIGNAL(immediateMessage(QString,QVariantMap )))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+
+ if (QLatin1String(signal) == SIGNAL(incomingMessage(QString,QVariantMap))) {
+ if(!connection().connect(QLatin1String(OFONO_SERVICE),
+ this->path(),
+ QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
+ QLatin1String("IncomingMessage"),
+ this,SIGNAL(incomingMessage(QString,QVariantMap)))) {
+ qWarning() << "PropertyCHanged not connected";
+ }
+ }
+}
+
+void QOfonoSmsInterface::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
+
+ }
+}
+
+QVariant QOfonoSmsInterface::getProperty(const QString &property)
+{
+ QVariant var;
+ QVariantMap map = getProperties();
+ if (map.contains(property)) {
+ var = map.value(property);
+ } else {
+ qDebug() << Q_FUNC_INFO << "does not contain" << property;
+ }
+ return var;
+}
+
+QVariantMap QOfonoSmsInterface::getProperties()
+{
+ QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
+ return reply.value();
+}
+
+void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message)
+{
+ QDBusReply<QString> reply = this->call(QLatin1String("SendMessage"),
+ QVariant::fromValue(to),
+ QVariant::fromValue(message));
+ bool ok = true;
+ if(reply.error().type() == QDBusError::InvalidArgs) {
+ qWarning() << reply.error().message();
+ ok = false;
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/connman/qofonoservice_linux_p.h b/src/plugins/bearer/connman/qofonoservice_linux_p.h
new file mode 100644
index 0000000000..af54ba0613
--- /dev/null
+++ b/src/plugins/bearer/connman/qofonoservice_linux_p.h
@@ -0,0 +1,340 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOFONOSERVICE_H
+#define QOFONOSERVICE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusContext>
+#include <QMap>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+#define OFONO_SERVICE "org.ofono"
+#define OFONO_MANAGER_INTERFACE "org.ofono.Manager"
+#define OFONO_MANAGER_PATH "/"
+#define OFONO_MODEM_INTERFACE "org.ofono.Modem"
+#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
+#define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.DataConnectionManager"
+#define OFONO_SIM_MANAGER_INTERFACE "org.ofono.SimManager"
+#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.PrimaryDataContext"
+
+#define OFONO_SMS_MANAGER_INTERFACE "org.ofono.SmsManager"
+#define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
+#define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
+
+
+
+QT_BEGIN_NAMESPACE
+
+QT_END_NAMESPACE
+
+
+QT_BEGIN_NAMESPACE
+
+class QOfonoManagerInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoManagerInterface( QObject *parent = 0);
+ ~QOfonoManagerInterface();
+
+ QDBusObjectPath path() const;
+
+ QVariantMap getProperties();
+ bool setProperty(const QString &name, const QDBusVariant &value);
+ QList <QDBusObjectPath> getModems();
+ QDBusObjectPath currentModem();
+
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+
+};
+
+
+class QOfonoDBusHelper: public QObject, protected QDBusContext
+ {
+ Q_OBJECT
+ public:
+ QOfonoDBusHelper(QObject *parent = 0);
+ ~QOfonoDBusHelper();
+
+ public slots:
+ void propertyChanged(const QString &, const QDBusVariant &);
+ Q_SIGNALS:
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+};
+
+class QOfonoModemInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0);
+ ~QOfonoModemInterface();
+
+ QVariantMap getProperties();
+ //properties
+ bool isPowered();
+ bool isOnline();
+ QString getName();
+ QString getManufacturer();
+ QString getModel();
+ QString getRevision();
+ QString getSerial();
+
+ QStringList getFeatures(); //sms, sim
+ QStringList getInterfaces();
+ QString defaultInterface();
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+};
+
+
+class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0);
+ ~QOfonoNetworkRegistrationInterface();
+
+ QVariantMap getProperties();
+
+ //properties
+ QString getStatus();
+ quint16 getLac();
+ quint32 getCellId();
+ QString getTechnology();
+ QString getOperatorName();
+ int getSignalStrength();
+ QString getBaseStation();
+ QList <QDBusObjectPath> getOperators();
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+
+};
+
+class QOfonoNetworkOperatorInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+//modem or operator paths
+ QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent = 0);
+ ~QOfonoNetworkOperatorInterface();
+
+ QVariantMap getProperties();
+
+ //properties
+ QString getName();
+ QString getStatus();// "unknown", "available", "current" and "forbidden"
+ QString getMcc();
+ QString getMnc();
+ QStringList getTechnologies();
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+};
+
+class QOfonoSimInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoSimInterface(const QString &dbusModemPathName, QObject *parent = 0);
+ ~QOfonoSimInterface();
+
+ QVariantMap getProperties();
+
+ //properties
+ bool isPresent();
+ QString getHomeMcc();
+ QString getHomeMnc();
+// QStringList subscriberNumbers();
+// QMap<QString,QString> serviceNumbers();
+ QString pinRequired();
+ QString lockedPins();
+ QString cardIdentifier();
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+};
+
+
+class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0);
+ ~QOfonoDataConnectionManagerInterface();
+
+ QVariantMap getProperties();
+
+ //properties
+ QList<QDBusObjectPath> getPrimaryContexts();
+ bool isAttached();
+ bool isRoamingAllowed();
+ bool isPowered();
+
+ bool setPower(bool on);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+};
+
+
+class QOfonoPrimaryDataContextInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent = 0);
+ ~QOfonoPrimaryDataContextInterface();
+
+ QVariantMap getProperties();
+
+ //properties
+ bool isActive();
+ QString getApName();
+ QString getType();
+ QString getName();
+ QVariantMap getSettings();
+ QString getInterface();
+ QString getAddress();
+
+ bool setActive(bool on);
+ bool setApn(const QString &name);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+ bool setProp(const QString &, const QVariant &var);
+};
+
+class QOfonoSmsInterface : public QDBusAbstractInterface
+{
+ Q_OBJECT
+
+public:
+
+ QOfonoSmsInterface(const QString &dbusModemPathName, QObject *parent = 0);
+ ~QOfonoSmsInterface();
+
+ QVariantMap getProperties();
+ void sendMessage(const QString &to, const QString &message);
+
+ //properties
+ QString serviceCenterAddress();
+ bool useDeliveryReports();
+ QString bearer();
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+ QVariant getProperty(const QString &);
+
+Q_SIGNALS:
+ void propertyChanged(const QString &, const QDBusVariant &value);
+ void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
+ void immediateMessage(const QString &message, const QVariantMap &info);
+ void incomingMessage(const QString &message, const QVariantMap &info);
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif //QOFONOSERVICE_H
diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro
new file mode 100644
index 0000000000..90078e9290
--- /dev/null
+++ b/src/plugins/bearer/corewlan/corewlan.pro
@@ -0,0 +1,25 @@
+TARGET = qcorewlanbearer
+include(../../qpluginbase.pri)
+
+QT = core network
+LIBS += -framework Foundation -framework SystemConfiguration
+
+contains(QT_CONFIG, corewlan) {
+ isEmpty(QMAKE_MAC_SDK)|contains(QMAKE_MAC_SDK, "/Developer/SDKs/MacOSX10.6.sdk") {
+ LIBS += -framework CoreWLAN -framework Security
+ DEFINES += MAC_SDK_10_6
+ }
+}
+
+HEADERS += qcorewlanengine.h \
+ ../qnetworksession_impl.h \
+ ../qbearerengine_impl.h
+
+SOURCES += main.cpp \
+ ../qnetworksession_impl.cpp
+
+OBJECTIVE_SOURCES += qcorewlanengine.mm
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
+target.path += $$[QT_INSTALL_PLUGINS]/bearer
+INSTALLS += target
diff --git a/src/plugins/bearer/corewlan/main.cpp b/src/plugins/bearer/corewlan/main.cpp
new file mode 100644
index 0000000000..7a5e7e30bd
--- /dev/null
+++ b/src/plugins/bearer/corewlan/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcorewlanengine.h"
+
+#include <QtNetwork/private/qbearerplugin_p.h>
+
+#include <QtCore/qdebug.h>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+class QCoreWlanEnginePlugin : public QBearerEnginePlugin
+{
+public:
+ QCoreWlanEnginePlugin();
+ ~QCoreWlanEnginePlugin();
+
+ QStringList keys() const;
+ QBearerEngine *create(const QString &key) const;
+};
+
+QCoreWlanEnginePlugin::QCoreWlanEnginePlugin()
+{
+}
+
+QCoreWlanEnginePlugin::~QCoreWlanEnginePlugin()
+{
+}
+
+QStringList QCoreWlanEnginePlugin::keys() const
+{
+ return QStringList() << QLatin1String("corewlan");
+}
+
+QBearerEngine *QCoreWlanEnginePlugin::create(const QString &key) const
+{
+ if (key == QLatin1String("corewlan"))
+ return new QCoreWlanEngine;
+ else
+ return 0;
+}
+
+Q_EXPORT_STATIC_PLUGIN(QCoreWlanEnginePlugin)
+Q_EXPORT_PLUGIN2(qcorewlanbearer, QCoreWlanEnginePlugin)
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
new file mode 100644
index 0000000000..428c79e3f5
--- /dev/null
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOREWLANENGINE_H
+#define QCOREWLANENGINE_H
+
+#include "../qbearerengine_impl.h"
+
+#include <QMap>
+#include <QTimer>
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <QThread>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkConfigurationPrivate;
+class QScanThread;
+
+class QCoreWlanEngine : public QBearerEngineImpl
+{
+ friend class QScanThread;
+ Q_OBJECT
+
+public:
+ QCoreWlanEngine(QObject *parent = 0);
+ ~QCoreWlanEngine();
+
+ QString getInterfaceFromId(const QString &id);
+ bool hasIdentifier(const QString &id);
+
+ void connectToId(const QString &id);
+ void disconnectFromId(const QString &id);
+
+ Q_INVOKABLE void initialize();
+ Q_INVOKABLE void requestUpdate();
+
+ QNetworkSession::State sessionStateForId(const QString &id);
+
+ quint64 bytesWritten(const QString &id);
+ quint64 bytesReceived(const QString &id);
+ quint64 startTime(const QString &id);
+
+ QNetworkConfigurationManager::Capabilities capabilities() const;
+
+ QNetworkSessionPrivate *createSessionBackend();
+
+ QNetworkConfigurationPrivatePointer defaultConfiguration();
+
+ bool requiresPolling() const;
+
+private Q_SLOTS:
+ void doRequestUpdate();
+ void networksChanged();
+
+private:
+ bool isWifiReady(const QString &dev);
+ QList<QNetworkConfigurationPrivate *> foundConfigurations;
+
+ SCDynamicStoreRef storeSession;
+ CFRunLoopSourceRef runloopSource;
+ bool hasWifi;
+ bool scanning;
+ QScanThread *scanThread;
+
+ quint64 getBytes(const QString &interfaceName,bool b);
+
+protected:
+ void startNetworkChangeLoop();
+
+};
+
+class QScanThread : public QThread
+{
+ Q_OBJECT
+
+public:
+ QScanThread(QObject *parent = 0);
+ ~QScanThread();
+
+ void quit();
+ QList<QNetworkConfigurationPrivate *> getConfigurations();
+ QString interfaceName;
+ QMap<QString, QString> configurationInterface;
+ void getUserConfigurations();
+ QString getNetworkNameFromSsid(const QString &ssid);
+ QString getSsidFromNetworkName(const QString &name);
+ bool isKnownSsid(const QString &ssid);
+ QMap<QString, QMap<QString,QString> > userProfiles;
+
+signals:
+ void networksChanged();
+
+protected:
+ void run();
+
+private:
+ QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
+ QMutex mutex;
+ QStringList foundNetwork(const QString &id, const QString &ssid, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose);
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
new file mode 100644
index 0000000000..07e74fec1f
--- /dev/null
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -0,0 +1,946 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcorewlanengine.h"
+#include "../qnetworksession_impl.h"
+
+#include <QtNetwork/private/qnetworkconfiguration_p.h>
+
+#include <QtCore/qthread.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qstringlist.h>
+
+#include <QtCore/qdebug.h>
+
+#include <QDir>
+#include <CoreWLAN/CoreWLAN.h>
+#include <CoreWLAN/CWInterface.h>
+#include <CoreWLAN/CWNetwork.h>
+#include <CoreWLAN/CWNetwork.h>
+#include <CoreWLAN/CW8021XProfile.h>
+
+#include <Foundation/NSEnumerator.h>
+#include <Foundation/NSKeyValueObserving.h>
+#include <Foundation/NSAutoreleasePool.h>
+#include <Foundation/NSLock.h>
+
+#include <SystemConfiguration/SCNetworkConfiguration.h>
+#include "private/qcore_mac_p.h"
+
+#include <net/if.h>
+#include <ifaddrs.h>
+
+inline QString qt_NSStringToQString(const NSString *nsstr)
+{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
+
+inline NSString *qt_QStringToNSString(const QString &qstr)
+{ return [reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr)) autorelease]; }
+
+
+@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
+{
+ NSNotificationCenter *notificationCenter;
+ CWInterface *currentInterface;
+ QCoreWlanEngine *engine;
+ NSLock *locker;
+}
+- (void)notificationHandler;//:(NSNotification *)notification;
+- (void)remove;
+- (void)setEngine:(QCoreWlanEngine *)coreEngine;
+- (void)dealloc;
+
+@property (assign) QCoreWlanEngine* engine;
+
+@end
+
+@implementation QT_MANGLE_NAMESPACE(QNSListener)
+@synthesize engine;
+
+- (id) init
+{
+ [locker lock];
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ notificationCenter = [NSNotificationCenter defaultCenter];
+ currentInterface = [CWInterface interfaceWithName:nil];
+ [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil];
+ [locker unlock];
+ [autoreleasepool release];
+ return self;
+}
+
+-(void)dealloc
+{
+ [super dealloc];
+}
+
+-(void)setEngine:(QCoreWlanEngine *)coreEngine
+{
+ [locker lock];
+ if(!engine)
+ engine = coreEngine;
+ [locker unlock];
+}
+
+-(void)remove
+{
+ [locker lock];
+ [notificationCenter removeObserver:self];
+ [locker unlock];
+}
+
+- (void)notificationHandler//:(NSNotification *)notification
+{
+ engine->requestUpdate();
+}
+@end
+
+QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
+
+QT_BEGIN_NAMESPACE
+
+void networkChangeCallback(SCDynamicStoreRef/* store*/, CFArrayRef changedKeys, void *info)
+{
+ for ( long i = 0; i < CFArrayGetCount(changedKeys); i++) {
+
+ QString changed = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(changedKeys, i));
+ if( changed.contains("/Network/Global/IPv4")) {
+ QCoreWlanEngine* wlanEngine = static_cast<QCoreWlanEngine*>(info);
+ wlanEngine->requestUpdate();
+ }
+ }
+ return;
+}
+
+
+QScanThread::QScanThread(QObject *parent)
+ :QThread(parent)
+{
+}
+
+QScanThread::~QScanThread()
+{
+}
+
+void QScanThread::quit()
+{
+ wait();
+}
+
+void QScanThread::run()
+{
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QStringList found;
+ mutex.lock();
+ CWInterface *currentInterface = [CWInterface interfaceWithName:qt_QStringToNSString(interfaceName)];
+ mutex.unlock();
+
+ if([currentInterface power]) {
+ NSError *err = nil;
+ NSDictionary *parametersDict = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:YES], kCWScanKeyMerge,
+ [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
+ [NSNumber numberWithInteger:100], kCWScanKeyRestTime, nil];
+
+ NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err];
+ CWNetwork *apNetwork;
+
+ if (!err) {
+
+ for(uint row=0; row < [apArray count]; row++ ) {
+ apNetwork = [apArray objectAtIndex:row];
+
+ const QString networkSsid = qt_NSStringToQString([apNetwork ssid]);
+ const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
+ found.append(id);
+
+ QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
+ bool known = isKnownSsid(networkSsid);
+ if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
+ if( networkSsid == qt_NSStringToQString( [currentInterface ssid])) {
+ state = QNetworkConfiguration::Active;
+ }
+ }
+ if(state == QNetworkConfiguration::Undefined) {
+ if(known) {
+ state = QNetworkConfiguration::Discovered;
+ } else {
+ state = QNetworkConfiguration::Undefined;
+ }
+ }
+ QNetworkConfiguration::Purpose purpose = QNetworkConfiguration::UnknownPurpose;
+ if([[apNetwork securityMode] intValue] == kCWSecurityModeOpen) {
+ purpose = QNetworkConfiguration::PublicPurpose;
+ } else {
+ purpose = QNetworkConfiguration::PrivatePurpose;
+ }
+
+ found.append(foundNetwork(id, networkSsid, state, interfaceName, purpose));
+
+ }
+ }
+ }
+ // add known configurations that are not around.
+ QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
+ while (i.hasNext()) {
+ i.next();
+
+ QString networkName = i.key();
+ const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkName));
+
+ if(!found.contains(id)) {
+ QString networkSsid = getSsidFromNetworkName(networkName);
+ const QString ssidId = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
+ QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
+ QString interfaceName;
+ QMapIterator<QString, QString> ij(i.value());
+ while (ij.hasNext()) {
+ ij.next();
+ interfaceName = ij.value();
+ }
+
+ if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
+ if( networkSsid == qt_NSStringToQString([currentInterface ssid])) {
+ state = QNetworkConfiguration::Active;
+ }
+ }
+ if(state == QNetworkConfiguration::Undefined) {
+ if( userProfiles.contains(networkName)
+ && found.contains(ssidId)) {
+ state = QNetworkConfiguration::Discovered;
+ }
+ }
+
+ if(state == QNetworkConfiguration::Undefined) {
+ state = QNetworkConfiguration::Defined;
+ }
+
+ found.append(foundNetwork(id, networkName, state, interfaceName, QNetworkConfiguration::UnknownPurpose));
+ }
+ }
+ emit networksChanged();
+ [autoreleasepool release];
+}
+
+QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
+{
+ QStringList found;
+ QMutexLocker locker(&mutex);
+ QNetworkConfigurationPrivate *ptr = new QNetworkConfigurationPrivate;
+
+ ptr->name = name;
+ ptr->isValid = true;
+ ptr->id = id;
+ ptr->state = state;
+ ptr->type = QNetworkConfiguration::InternetAccessPoint;
+ ptr->bearerType = QNetworkConfiguration::BearerWLAN;
+ ptr->purpose = purpose;
+
+ fetchedConfigurations.append( ptr);
+ configurationInterface.insert(ptr->id, interfaceName);
+
+ locker.unlock();
+ locker.relock();
+ found.append(id);
+ return found;
+}
+
+QList<QNetworkConfigurationPrivate *> QScanThread::getConfigurations()
+{
+ QMutexLocker locker(&mutex);
+
+ QList<QNetworkConfigurationPrivate *> foundConfigurations = fetchedConfigurations;
+ fetchedConfigurations.clear();
+
+ return foundConfigurations;
+}
+
+void QScanThread::getUserConfigurations()
+{
+ QMutexLocker locker(&mutex);
+
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ userProfiles.clear();
+
+ NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
+ for(uint row=0; row < [wifiInterfaces count]; row++ ) {
+
+ CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]];
+ if ( ![wifiInterface power] )
+ continue;
+
+ NSString *nsInterfaceName = [wifiInterface name];
+// add user configured system networks
+ SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil);
+ NSDictionary * airportPlist = (NSDictionary *)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", nsInterfaceName]);
+ CFRelease(dynRef);
+ if(airportPlist != nil) {
+ NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"];
+
+ NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"];
+ for(NSString *ssidkey in thisSsidarray) {
+ QString thisSsid = qt_NSStringToQString(ssidkey);
+ if(!userProfiles.contains(thisSsid)) {
+ QMap <QString,QString> map;
+ map.insert(thisSsid, qt_NSStringToQString(nsInterfaceName));
+ userProfiles.insert(thisSsid, map);
+ }
+ }
+ CFRelease(airportPlist);
+ }
+
+ // 802.1X user profiles
+ QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist";
+ NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:qt_QStringToNSString(userProfilePath)] autorelease];
+ if(eapDict != nil) {
+ NSString *profileStr= @"Profiles";
+ NSString *nameStr = @"UserDefinedName";
+ NSString *networkSsidStr = @"Wireless Network";
+ for (id profileKey in eapDict) {
+ if ([profileStr isEqualToString:profileKey]) {
+ NSDictionary *itemDict = [eapDict objectForKey:profileKey];
+ for (id itemKey in itemDict) {
+
+ NSInteger dictSize = [itemKey count];
+ id objects[dictSize];
+ id keys[dictSize];
+
+ [itemKey getObjects:objects andKeys:keys];
+ QString networkName;
+ QString ssid;
+ for(int i = 0; i < dictSize; i++) {
+ if([nameStr isEqualToString:keys[i]]) {
+ networkName = qt_NSStringToQString(objects[i]);
+ }
+ if([networkSsidStr isEqualToString:keys[i]]) {
+ ssid = qt_NSStringToQString(objects[i]);
+ }
+ if(!userProfiles.contains(networkName)
+ && !ssid.isEmpty()) {
+ QMap<QString,QString> map;
+ map.insert(ssid, qt_NSStringToQString(nsInterfaceName));
+ userProfiles.insert(networkName, map);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ [autoreleasepool release];
+}
+
+QString QScanThread::getSsidFromNetworkName(const QString &name)
+{
+ QMutexLocker locker(&mutex);
+
+ QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
+ while (i.hasNext()) {
+ i.next();
+ QMap<QString,QString> map = i.value();
+ QMapIterator<QString, QString> ij(i.value());
+ while (ij.hasNext()) {
+ ij.next();
+ const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") +i.key()));
+ if(name == i.key() || name == networkNameHash) {
+ return ij.key();
+ }
+ }
+ }
+ return QString();
+}
+
+QString QScanThread::getNetworkNameFromSsid(const QString &ssid)
+{
+ QMutexLocker locker(&mutex);
+
+ QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
+ while (i.hasNext()) {
+ i.next();
+ QMap<QString,QString> map = i.value();
+ QMapIterator<QString, QString> ij(i.value());
+ while (ij.hasNext()) {
+ ij.next();
+ if(ij.key() == ssid) {
+ return i.key();
+ }
+ }
+ }
+ return QString();
+}
+
+bool QScanThread::isKnownSsid(const QString &ssid)
+{
+ QMutexLocker locker(&mutex);
+
+ QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
+ while (i.hasNext()) {
+ i.next();
+ QMap<QString,QString> map = i.value();
+ if(map.keys().contains(ssid)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
+: QBearerEngineImpl(parent), scanThread(0)
+{
+ scanThread = new QScanThread(this);
+ connect(scanThread, SIGNAL(networksChanged()),
+ this, SLOT(networksChanged()));
+}
+
+QCoreWlanEngine::~QCoreWlanEngine()
+{
+ while (!foundConfigurations.isEmpty())
+ delete foundConfigurations.takeFirst();
+ [listener remove];
+ [listener release];
+}
+
+void QCoreWlanEngine::initialize()
+{
+ QMutexLocker locker(&mutex);
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+ if([[CWInterface supportedInterfaces] count] > 0 && !listener) {
+ listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
+ listener.engine = this;
+ hasWifi = true;
+ } else {
+ hasWifi = false;
+ }
+ storeSession = NULL;
+
+ startNetworkChangeLoop();
+ [autoreleasepool release];
+}
+
+
+QString QCoreWlanEngine::getInterfaceFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ return scanThread->configurationInterface.value(id);
+}
+
+bool QCoreWlanEngine::hasIdentifier(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ return scanThread->configurationInterface.contains(id);
+}
+
+void QCoreWlanEngine::connectToId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QString interfaceString = getInterfaceFromId(id);
+
+ CWInterface *wifiInterface =
+ [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
+
+ if ([wifiInterface power]) {
+ NSError *err = nil;
+ NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
+
+ QString wantedSsid;
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ const QString idHash = QString::number(qHash(QLatin1String("corewlan:") + ptr->name));
+ const QString idHash2 = QString::number(qHash(QLatin1String("corewlan:") + scanThread->getNetworkNameFromSsid(ptr->name)));
+
+ bool using8021X = false;
+ if (idHash2 != id) {
+ NSArray *array = [CW8021XProfile allUser8021XProfiles];
+
+ for (NSUInteger i = 0; i < [array count]; ++i) {
+ const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] userDefinedName])));
+
+ const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] ssid])));
+
+ if (id == networkNameHashCheck || id == ssidHash) {
+ const QString thisName = scanThread->getSsidFromNetworkName(id);
+ if (thisName.isEmpty())
+ wantedSsid = id;
+ else
+ wantedSsid = thisName;
+
+ [params setValue: [array objectAtIndex:i] forKey:kCWAssocKey8021XProfile];
+ using8021X = true;
+ break;
+ }
+ }
+ }
+
+ if (!using8021X) {
+ QString wantedNetwork;
+ QMapIterator<QString, QMap<QString,QString> > i(scanThread->userProfiles);
+ while (i.hasNext()) {
+ i.next();
+ wantedNetwork = i.key();
+ const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork));
+ if (id == networkNameHash) {
+ wantedSsid = scanThread->getSsidFromNetworkName(wantedNetwork);
+ break;
+ }
+ }
+ }
+ NSDictionary *scanParameters = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:YES], kCWScanKeyMerge,
+ [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
+ [NSNumber numberWithInteger:100], kCWScanKeyRestTime,
+ qt_QStringToNSString(wantedSsid), kCWScanKeySSID,
+ nil];
+
+ NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err];
+
+ if(!err) {
+ for(uint row=0; row < [scanArray count]; row++ ) {
+ CWNetwork *apNetwork = [scanArray objectAtIndex:row];
+
+ if(wantedSsid == qt_NSStringToQString([apNetwork ssid])) {
+
+ if(!using8021X) {
+ SecKeychainAttribute attributes[3];
+
+ NSString *account = [apNetwork ssid];
+ NSString *keyKind = @"AirPort network password";
+ NSString *keyName = account;
+
+ attributes[0].tag = kSecAccountItemAttr;
+ attributes[0].data = (void *)[account UTF8String];
+ attributes[0].length = [account length];
+
+ attributes[1].tag = kSecDescriptionItemAttr;
+ attributes[1].data = (void *)[keyKind UTF8String];
+ attributes[1].length = [keyKind length];
+
+ attributes[2].tag = kSecLabelItemAttr;
+ attributes[2].data = (void *)[keyName UTF8String];
+ attributes[2].length = [keyName length];
+
+ SecKeychainAttributeList attributeList = {3,attributes};
+
+ SecKeychainSearchRef searchRef;
+ SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, &attributeList, &searchRef);
+
+ NSString *password = @"";
+ SecKeychainItemRef searchItem;
+
+ if (SecKeychainSearchCopyNext(searchRef, &searchItem) == noErr) {
+ UInt32 realPasswordLength;
+ SecKeychainAttribute attributesW[8];
+ attributesW[0].tag = kSecAccountItemAttr;
+ SecKeychainAttributeList listW = {1,attributesW};
+ char *realPassword;
+ OSStatus status = SecKeychainItemCopyContent(searchItem, NULL, &listW, &realPasswordLength,(void **)&realPassword);
+
+ if (status == noErr) {
+ if (realPassword != NULL) {
+
+ QByteArray pBuf;
+ pBuf.resize(realPasswordLength);
+ pBuf.prepend(realPassword);
+ pBuf.insert(realPasswordLength,'\0');
+
+ password = [NSString stringWithUTF8String:pBuf];
+ }
+ SecKeychainItemFreeContent(&listW, realPassword);
+ }
+
+ CFRelease(searchItem);
+ } else {
+ qDebug() << "SecKeychainSearchCopyNext error";
+ }
+ [params setValue: password forKey: kCWAssocKeyPassphrase];
+ } // end using8021X
+
+
+ bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err];
+
+ if(!err) {
+ if(!result) {
+ emit connectionError(id, ConnectError);
+ } else {
+ return;
+ }
+ } else {
+ qDebug() <<"associate ERROR"<< qt_NSStringToQString([err localizedDescription ]);
+ }
+ }
+ } //end scan network
+ } else {
+ qDebug() <<"scan ERROR"<< qt_NSStringToQString([err localizedDescription ]);
+ }
+ emit connectionError(id, InterfaceLookupError);
+ }
+
+ locker.unlock();
+ emit connectionError(id, InterfaceLookupError);
+ [autoreleasepool release];
+}
+
+void QCoreWlanEngine::disconnectFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QString interfaceString = getInterfaceFromId(id);
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+ CWInterface *wifiInterface =
+ [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
+
+ [wifiInterface disassociate];
+ if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
+ locker.unlock();
+ emit connectionError(id, DisconnectionError);
+ locker.relock();
+ }
+ [autoreleasepool release];
+}
+
+void QCoreWlanEngine::requestUpdate()
+{
+ scanThread->getUserConfigurations();
+ doRequestUpdate();
+}
+
+void QCoreWlanEngine::doRequestUpdate()
+{
+ QMutexLocker locker(&mutex);
+
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+ NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
+ for (uint row = 0; row < [wifiInterfaces count]; ++row) {
+ scanThread->interfaceName = qt_NSStringToQString([wifiInterfaces objectAtIndex:row]);
+ scanThread->start();
+ }
+ locker.unlock();
+ [autoreleasepool release];
+}
+
+bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
+{
+ QMutexLocker locker(&mutex);
+ bool haswifi = false;
+ if(hasWifi) {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ CWInterface *defaultInterface = [CWInterface interfaceWithName: qt_QStringToNSString(wifiDeviceName)];
+ if([defaultInterface power]) {
+ haswifi = true;
+ }
+ [autoreleasepool release];
+ }
+ return haswifi;
+}
+
+
+QNetworkSession::State QCoreWlanEngine::sessionStateForId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ if (!ptr)
+ return QNetworkSession::Invalid;
+
+ if (!ptr->isValid) {
+ return QNetworkSession::Invalid;
+ } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ return QNetworkSession::Connected;
+ } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
+ QNetworkConfiguration::Discovered) {
+ return QNetworkSession::Disconnected;
+ } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
+ return QNetworkSession::NotAvailable;
+ } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
+ QNetworkConfiguration::Undefined) {
+ return QNetworkSession::NotAvailable;
+ }
+
+ return QNetworkSession::Invalid;
+}
+
+QNetworkConfigurationManager::Capabilities QCoreWlanEngine::capabilities() const
+{
+ return QNetworkConfigurationManager::ForcedRoaming;
+}
+
+void QCoreWlanEngine::startNetworkChangeLoop()
+{
+
+ SCDynamicStoreContext dynStoreContext = { 0, this/*(void *)storeSession*/, NULL, NULL, NULL };
+ storeSession = SCDynamicStoreCreate(NULL,
+ CFSTR("networkChangeCallback"),
+ networkChangeCallback,
+ &dynStoreContext);
+ if (!storeSession ) {
+ qWarning() << "could not open dynamic store: error:" << SCErrorString(SCError());
+ return;
+ }
+
+ CFMutableArrayRef notificationKeys;
+ notificationKeys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ CFMutableArrayRef patternsArray;
+ patternsArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+
+ CFStringRef storeKey;
+ storeKey = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
+ kSCDynamicStoreDomainState,
+ kSCEntNetIPv4);
+ CFArrayAppendValue(notificationKeys, storeKey);
+ CFRelease(storeKey);
+
+ storeKey = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,
+ kSCDynamicStoreDomainState,
+ kSCCompAnyRegex,
+ kSCEntNetIPv4);
+ CFArrayAppendValue(patternsArray, storeKey);
+ CFRelease(storeKey);
+
+ if (!SCDynamicStoreSetNotificationKeys(storeSession , notificationKeys, patternsArray)) {
+ qWarning() << "register notification error:"<< SCErrorString(SCError());
+ CFRelease(storeSession );
+ CFRelease(notificationKeys);
+ CFRelease(patternsArray);
+ return;
+ }
+ CFRelease(notificationKeys);
+ CFRelease(patternsArray);
+
+ runloopSource = SCDynamicStoreCreateRunLoopSource(NULL, storeSession , 0);
+ if (!runloopSource) {
+ qWarning() << "runloop source error:"<< SCErrorString(SCError());
+ CFRelease(storeSession );
+ return;
+ }
+
+ CFRunLoopAddSource(CFRunLoopGetCurrent(), runloopSource, kCFRunLoopDefaultMode);
+ return;
+}
+
+QNetworkSessionPrivate *QCoreWlanEngine::createSessionBackend()
+{
+ return new QNetworkSessionPrivateImpl;
+}
+
+QNetworkConfigurationPrivatePointer QCoreWlanEngine::defaultConfiguration()
+{
+ return QNetworkConfigurationPrivatePointer();
+}
+
+bool QCoreWlanEngine::requiresPolling() const
+{
+ return true;
+}
+
+void QCoreWlanEngine::networksChanged()
+{
+ QMutexLocker locker(&mutex);
+
+ QStringList previous = accessPointConfigurations.keys();
+
+ QList<QNetworkConfigurationPrivate *> foundConfigurations = scanThread->getConfigurations();
+ while (!foundConfigurations.isEmpty()) {
+ QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
+
+ previous.removeAll(cpPriv->id);
+
+ if (accessPointConfigurations.contains(cpPriv->id)) {
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
+
+ bool changed = false;
+
+ ptr->mutex.lock();
+
+ if (ptr->isValid != cpPriv->isValid) {
+ ptr->isValid = cpPriv->isValid;
+ changed = true;
+ }
+
+ if (ptr->name != cpPriv->name) {
+ ptr->name = cpPriv->name;
+ changed = true;
+ }
+
+ if (ptr->bearerType != cpPriv->bearerType) {
+ ptr->bearerType = cpPriv->bearerType;
+ changed = true;
+ }
+
+ if (ptr->state != cpPriv->state) {
+ ptr->state = cpPriv->state;
+ changed = true;
+ }
+
+ ptr->mutex.unlock();
+
+ if (changed) {
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ }
+
+ delete cpPriv;
+ } else {
+ QNetworkConfigurationPrivatePointer ptr(cpPriv);
+
+ accessPointConfigurations.insert(ptr->id, ptr);
+
+ locker.unlock();
+ emit configurationAdded(ptr);
+ locker.relock();
+ }
+ }
+
+ while (!previous.isEmpty()) {
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.take(previous.takeFirst());
+
+ locker.unlock();
+ emit configurationRemoved(ptr);
+ locker.relock();
+ }
+
+ locker.unlock();
+ emit updateCompleted();
+
+}
+
+quint64 QCoreWlanEngine::bytesWritten(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ const QString interfaceStr = getInterfaceFromId(id);
+ return getBytes(interfaceStr,false);
+}
+
+quint64 QCoreWlanEngine::bytesReceived(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+ const QString interfaceStr = getInterfaceFromId(id);
+ return getBytes(interfaceStr,true);
+}
+
+quint64 QCoreWlanEngine::startTime(const QString &identifier)
+{
+ QMutexLocker locker(&mutex);
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ quint64 timestamp = 0;
+
+ NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
+ NSDictionary* plistDict = [[[NSDictionary alloc] initWithContentsOfFile:filePath] autorelease];
+ if(plistDict == nil)
+ return timestamp;
+ NSString *input = @"KnownNetworks";
+ NSString *timeStampStr = @"_timeStamp";
+
+ NSString *ssidStr = @"SSID_STR";
+
+ for (id key in plistDict) {
+ if ([input isEqualToString:key]) {
+
+ NSDictionary *knownNetworksDict = [plistDict objectForKey:key];
+ if(knownNetworksDict == nil)
+ return timestamp;
+ for (id networkKey in knownNetworksDict) {
+ bool isFound = false;
+ NSDictionary *itemDict = [knownNetworksDict objectForKey:networkKey];
+ if(itemDict == nil)
+ return timestamp;
+ NSInteger dictSize = [itemDict count];
+ id objects[dictSize];
+ id keys[dictSize];
+
+ [itemDict getObjects:objects andKeys:keys];
+ bool ok = false;
+ for(int i = 0; i < dictSize; i++) {
+ if([ssidStr isEqualToString:keys[i]]) {
+ const QString ident = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString(objects[i])));
+ if(ident == identifier) {
+ ok = true;
+ }
+ }
+ if(ok && [timeStampStr isEqualToString:keys[i]]) {
+ timestamp = (quint64)[objects[i] timeIntervalSince1970];
+ isFound = true;
+ break;
+ }
+ }
+ if(isFound)
+ break;
+ }
+ }
+ }
+ [autoreleasepool release];
+ return timestamp;
+}
+
+quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
+{
+ struct ifaddrs *ifAddressList, *ifAddress;
+ struct if_data *if_data;
+
+ quint64 bytes = 0;
+ ifAddressList = nil;
+ if(getifaddrs(&ifAddressList) == 0) {
+ for(ifAddress = ifAddressList; ifAddress; ifAddress = ifAddress->ifa_next) {
+ if(interfaceName == ifAddress->ifa_name) {
+ if_data = (struct if_data*)ifAddress->ifa_data;
+ if(b) {
+ bytes = if_data->ifi_ibytes;
+ break;
+ } else {
+ bytes = if_data->ifi_obytes;
+ break;
+ }
+ }
+ }
+ freeifaddrs(ifAddressList);
+ }
+ return bytes;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro
new file mode 100644
index 0000000000..c967f8c6dc
--- /dev/null
+++ b/src/plugins/bearer/generic/generic.pro
@@ -0,0 +1,16 @@
+TARGET = qgenericbearer
+include(../../qpluginbase.pri)
+
+QT = core network
+
+HEADERS += qgenericengine.h \
+ ../qnetworksession_impl.h \
+ ../qbearerengine_impl.h \
+ ../platformdefs_win.h
+SOURCES += qgenericengine.cpp \
+ ../qnetworksession_impl.cpp \
+ main.cpp
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
+target.path += $$[QT_INSTALL_PLUGINS]/bearer
+INSTALLS += target
diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp
new file mode 100644
index 0000000000..2b9eedc066
--- /dev/null
+++ b/src/plugins/bearer/generic/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgenericengine.h"
+
+#include <QtNetwork/private/qbearerplugin_p.h>
+
+#include <QtCore/qdebug.h>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+class QGenericEnginePlugin : public QBearerEnginePlugin
+{
+public:
+ QGenericEnginePlugin();
+ ~QGenericEnginePlugin();
+
+ QStringList keys() const;
+ QBearerEngine *create(const QString &key) const;
+};
+
+QGenericEnginePlugin::QGenericEnginePlugin()
+{
+}
+
+QGenericEnginePlugin::~QGenericEnginePlugin()
+{
+}
+
+QStringList QGenericEnginePlugin::keys() const
+{
+ return QStringList() << QLatin1String("generic");
+}
+
+QBearerEngine *QGenericEnginePlugin::create(const QString &key) const
+{
+ if (key == QLatin1String("generic"))
+ return new QGenericEngine;
+ else
+ return 0;
+}
+
+Q_EXPORT_STATIC_PLUGIN(QGenericEnginePlugin)
+Q_EXPORT_PLUGIN2(qgenericbearer, QGenericEnginePlugin)
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
new file mode 100644
index 0000000000..2e183cf395
--- /dev/null
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -0,0 +1,359 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgenericengine.h"
+#include "../qnetworksession_impl.h"
+
+#include <QtNetwork/private/qnetworkconfiguration_p.h>
+
+#include <QtCore/qthread.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qstringlist.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/private/qcoreapplication_p.h>
+
+#ifdef Q_OS_WIN
+#include "../platformdefs_win.h"
+#endif
+
+#ifdef Q_OS_LINUX
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <unistd.h>
+#endif
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_NETWORKINTERFACE
+static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
+{
+#ifdef Q_OS_WIN32
+ unsigned long oid;
+ DWORD bytesWritten;
+
+ NDIS_MEDIUM medium;
+ NDIS_PHYSICAL_MEDIUM physicalMedium;
+
+ HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0,
+ FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+ if (handle == INVALID_HANDLE_VALUE)
+ return QNetworkConfiguration::BearerUnknown;
+
+ oid = OID_GEN_MEDIA_SUPPORTED;
+ bytesWritten = 0;
+ bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
+ &medium, sizeof(medium), &bytesWritten, 0);
+ if (!result) {
+ CloseHandle(handle);
+ return QNetworkConfiguration::BearerUnknown;
+ }
+
+ oid = OID_GEN_PHYSICAL_MEDIUM;
+ bytesWritten = 0;
+ result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
+ &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0);
+ if (!result) {
+ CloseHandle(handle);
+
+ if (medium == NdisMedium802_3)
+ return QNetworkConfiguration::BearerEthernet;
+ else
+ return QNetworkConfiguration::BearerUnknown;
+ }
+
+ CloseHandle(handle);
+
+ if (medium == NdisMedium802_3) {
+ switch (physicalMedium) {
+ case NdisPhysicalMediumWirelessLan:
+ return QNetworkConfiguration::BearerWLAN;
+ case NdisPhysicalMediumBluetooth:
+ return QNetworkConfiguration::BearerBluetooth;
+ case NdisPhysicalMediumWiMax:
+ return QNetworkConfiguration::BearerWiMAX;
+ default:
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug() << "Physical Medium" << physicalMedium;
+#endif
+ return QNetworkConfiguration::BearerEthernet;
+ }
+ }
+
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug() << medium << physicalMedium;
+#endif
+#elif defined(Q_OS_LINUX)
+ int sock = socket(AF_INET, SOCK_DGRAM, 0);
+
+ ifreq request;
+ strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
+ int result = ioctl(sock, SIOCGIFHWADDR, &request);
+ close(sock);
+
+ if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
+ return QNetworkConfiguration::BearerEthernet;
+#else
+ Q_UNUSED(interface);
+#endif
+
+ return QNetworkConfiguration::BearerUnknown;
+}
+#endif
+
+QGenericEngine::QGenericEngine(QObject *parent)
+: QBearerEngineImpl(parent)
+{
+}
+
+QGenericEngine::~QGenericEngine()
+{
+}
+
+QString QGenericEngine::getInterfaceFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ return configurationInterface.value(id);
+}
+
+bool QGenericEngine::hasIdentifier(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ return configurationInterface.contains(id);
+}
+
+void QGenericEngine::connectToId(const QString &id)
+{
+ emit connectionError(id, OperationNotSupported);
+}
+
+void QGenericEngine::disconnectFromId(const QString &id)
+{
+ emit connectionError(id, OperationNotSupported);
+}
+
+void QGenericEngine::initialize()
+{
+ doRequestUpdate();
+}
+
+void QGenericEngine::requestUpdate()
+{
+ doRequestUpdate();
+}
+
+void QGenericEngine::doRequestUpdate()
+{
+#ifndef QT_NO_NETWORKINTERFACE
+ QMutexLocker locker(&mutex);
+
+ // Immediately after connecting with a wireless access point
+ // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a
+ // second time results in a non-empty list. If we loose interfaces we will end up removing
+ // network configurations which will break current sessions.
+ QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
+ if (interfaces.isEmpty())
+ interfaces = QNetworkInterface::allInterfaces();
+
+ QStringList previous = accessPointConfigurations.keys();
+
+ // create configuration for each interface
+ while (!interfaces.isEmpty()) {
+ QNetworkInterface interface = interfaces.takeFirst();
+
+ if (!interface.isValid())
+ continue;
+
+ // ignore loopback interface
+ if (interface.flags() & QNetworkInterface::IsLoopBack)
+ continue;
+
+ // ignore WLAN interface handled in separate engine
+ if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN)
+ continue;
+
+ uint identifier;
+ if (interface.index())
+ identifier = qHash(QLatin1String("generic:") + QString::number(interface.index()));
+ else
+ identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress());
+
+ const QString id = QString::number(identifier);
+
+ previous.removeAll(id);
+
+ QString name = interface.humanReadableName();
+ if (name.isEmpty())
+ name = interface.name();
+
+ QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined;
+ if((interface.flags() & QNetworkInterface::IsUp) && !interface.addressEntries().isEmpty())
+ state |= QNetworkConfiguration::Active;
+
+ if (accessPointConfigurations.contains(id)) {
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ bool changed = false;
+
+ ptr->mutex.lock();
+
+ if (!ptr->isValid) {
+ ptr->isValid = true;
+ changed = true;
+ }
+
+ if (ptr->name != name) {
+ ptr->name = name;
+ changed = true;
+ }
+
+ if (ptr->id != id) {
+ ptr->id = id;
+ changed = true;
+ }
+
+ if (ptr->state != state) {
+ ptr->state = state;
+ changed = true;
+ }
+
+ ptr->mutex.unlock();
+
+ if (changed) {
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ }
+ } else {
+ QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
+
+ ptr->name = name;
+ ptr->isValid = true;
+ ptr->id = id;
+ ptr->state = state;
+ ptr->type = QNetworkConfiguration::InternetAccessPoint;
+ ptr->bearerType = qGetInterfaceType(interface.name());
+
+ accessPointConfigurations.insert(id, ptr);
+ configurationInterface.insert(id, interface.name());
+
+ locker.unlock();
+ emit configurationAdded(ptr);
+ locker.relock();
+ }
+ }
+
+ while (!previous.isEmpty()) {
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.take(previous.takeFirst());
+
+ configurationInterface.remove(ptr->id);
+
+ locker.unlock();
+ emit configurationRemoved(ptr);
+ locker.relock();
+ }
+
+ locker.unlock();
+#endif
+
+ emit updateCompleted();
+}
+
+QNetworkSession::State QGenericEngine::sessionStateForId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ if (!ptr)
+ return QNetworkSession::Invalid;
+
+ QMutexLocker configLocker(&ptr->mutex);
+
+ if (!ptr->isValid) {
+ return QNetworkSession::Invalid;
+ } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ return QNetworkSession::Connected;
+ } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
+ QNetworkConfiguration::Discovered) {
+ return QNetworkSession::Disconnected;
+ } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
+ return QNetworkSession::NotAvailable;
+ } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
+ QNetworkConfiguration::Undefined) {
+ return QNetworkSession::NotAvailable;
+ }
+
+ return QNetworkSession::Invalid;
+}
+
+QNetworkConfigurationManager::Capabilities QGenericEngine::capabilities() const
+{
+ return QNetworkConfigurationManager::ForcedRoaming;
+}
+
+QNetworkSessionPrivate *QGenericEngine::createSessionBackend()
+{
+ return new QNetworkSessionPrivateImpl;
+}
+
+QNetworkConfigurationPrivatePointer QGenericEngine::defaultConfiguration()
+{
+ return QNetworkConfigurationPrivatePointer();
+}
+
+
+bool QGenericEngine::requiresPolling() const
+{
+ return true;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h
new file mode 100644
index 0000000000..30f69b538f
--- /dev/null
+++ b/src/plugins/bearer/generic/qgenericengine.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGENERICENGINE_H
+#define QGENERICENGINE_H
+
+#include "../qbearerengine_impl.h"
+
+#include <QMap>
+#include <QTimer>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkConfigurationPrivate;
+class QNetworkSessionPrivate;
+
+class QGenericEngine : public QBearerEngineImpl
+{
+ Q_OBJECT
+
+public:
+ QGenericEngine(QObject *parent = 0);
+ ~QGenericEngine();
+
+ QString getInterfaceFromId(const QString &id);
+ bool hasIdentifier(const QString &id);
+
+ void connectToId(const QString &id);
+ void disconnectFromId(const QString &id);
+
+ Q_INVOKABLE void initialize();
+ Q_INVOKABLE void requestUpdate();
+
+ QNetworkSession::State sessionStateForId(const QString &id);
+
+ QNetworkConfigurationManager::Capabilities capabilities() const;
+
+ QNetworkSessionPrivate *createSessionBackend();
+
+ QNetworkConfigurationPrivatePointer defaultConfiguration();
+
+ bool requiresPolling() const;
+
+private Q_SLOTS:
+ void doRequestUpdate();
+
+private:
+ QMap<QString, QString> configurationInterface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif
+
diff --git a/src/plugins/bearer/icd/dbusdispatcher.cpp b/src/plugins/bearer/icd/dbusdispatcher.cpp
new file mode 100644
index 0000000000..a317cb4944
--- /dev/null
+++ b/src/plugins/bearer/icd/dbusdispatcher.cpp
@@ -0,0 +1,634 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QDebug>
+#include <QtCore>
+#include <poll.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <glib.h>
+#include "dbusdispatcher.h"
+
+namespace Maemo {
+
+/*!
+ \class Maemo::DBusDispatcher
+
+ \brief DBusDispatcher is a class that can send DBUS method call
+ messages and receive unicast signals from DBUS objects.
+*/
+
+class DBusDispatcherPrivate
+{
+public:
+ DBusDispatcherPrivate(const QString& service,
+ const QString& path,
+ const QString& interface,
+ const QString& signalPath)
+ : service(service), path(path), interface(interface),
+ signalPath(signalPath), connection(0)
+ {
+ memset(&signal_vtable, 0, sizeof(signal_vtable));
+ }
+
+ ~DBusDispatcherPrivate()
+ {
+ foreach(DBusPendingCall *call, pending_calls) {
+ dbus_pending_call_cancel(call);
+ dbus_pending_call_unref(call);
+ }
+ }
+
+ QString service;
+ QString path;
+ QString interface;
+ QString signalPath;
+ struct DBusConnection *connection;
+ QList<DBusPendingCall *> pending_calls;
+ struct DBusObjectPathVTable signal_vtable;
+};
+
+static bool constantVariantList(const QVariantList& variantList) {
+ // Special case, empty list == empty struct
+ if (variantList.isEmpty()) {
+ return false;
+ } else {
+ QVariant::Type type = variantList[0].type();
+ // Iterate items in the list and check if they are same type
+ foreach(QVariant variant, variantList) {
+ if (variant.type() != type) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+static QString variantToSignature(const QVariant& argument,
+ bool constantList = true) {
+ switch (argument.type()) {
+ case QVariant::Bool:
+ return "b";
+ case QVariant::ByteArray:
+ return "ay";
+ case QVariant::Char:
+ return "y";
+ case QVariant::Int:
+ return "i";
+ case QVariant::UInt:
+ return "u";
+ case QVariant::StringList:
+ return "as";
+ case QVariant::String:
+ return "s";
+ case QVariant::LongLong:
+ return "x";
+ case QVariant::ULongLong:
+ return "t";
+ case QVariant::List:
+ {
+ QString signature;
+ QVariantList variantList = argument.toList();
+ if (!constantList) {
+ signature += DBUS_STRUCT_BEGIN_CHAR_AS_STRING;
+ foreach(QVariant listItem, variantList) {
+ signature += variantToSignature(listItem);
+ }
+ signature += DBUS_STRUCT_END_CHAR_AS_STRING;
+ } else {
+ if (variantList.isEmpty())
+ return "";
+ signature = "a" + variantToSignature(variantList[0]);
+ }
+
+ return signature;
+ }
+ default:
+ qDebug() << "Unsupported variant type: " << argument.type();
+ break;
+ }
+
+ return "";
+}
+
+static bool appendVariantToDBusMessage(const QVariant& argument,
+ DBusMessageIter *dbus_iter) {
+ int idx = 0;
+ DBusMessageIter array_iter;
+ QStringList str_list;
+ dbus_bool_t bool_data;
+ dbus_int32_t int32_data;
+ dbus_uint32_t uint32_data;
+ dbus_int64_t int64_data;
+ dbus_uint64_t uint64_data;
+ char *str_data;
+ char char_data;
+
+ switch (argument.type()) {
+
+ case QVariant::Bool:
+ bool_data = argument.toBool();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_BOOLEAN,
+ &bool_data);
+ break;
+
+ case QVariant::ByteArray:
+ str_data = argument.toByteArray().data();
+ dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_BYTE_AS_STRING, &array_iter);
+ dbus_message_iter_append_fixed_array(&array_iter,
+ DBUS_TYPE_BYTE,
+ &str_data,
+ argument.toByteArray().size());
+ dbus_message_iter_close_container(dbus_iter, &array_iter);
+ break;
+
+ case QVariant::Char:
+ char_data = argument.toChar().toAscii();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_BYTE,
+ &char_data);
+ break;
+
+ case QVariant::Int:
+ int32_data = argument.toInt();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_INT32,
+ &int32_data);
+ break;
+
+ case QVariant::String: {
+ QByteArray data = argument.toString().toLatin1();
+ str_data = data.data();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_STRING,
+ &str_data);
+ break;
+ }
+
+ case QVariant::StringList:
+ str_list = argument.toStringList();
+ dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY,
+ "s", &array_iter);
+ for (idx = 0; idx < str_list.size(); idx++) {
+ QByteArray data = str_list.at(idx).toLatin1();
+ str_data = data.data();
+ dbus_message_iter_append_basic(&array_iter,
+ DBUS_TYPE_STRING,
+ &str_data);
+ }
+ dbus_message_iter_close_container(dbus_iter, &array_iter);
+ break;
+
+ case QVariant::UInt:
+ uint32_data = argument.toUInt();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_UINT32,
+ &uint32_data);
+ break;
+
+ case QVariant::ULongLong:
+ uint64_data = argument.toULongLong();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_UINT64,
+ &uint64_data);
+ break;
+
+ case QVariant::LongLong:
+ int64_data = argument.toLongLong();
+ dbus_message_iter_append_basic(dbus_iter, DBUS_TYPE_INT64,
+ &int64_data);
+ break;
+
+ case QVariant::List:
+ {
+ QVariantList variantList = argument.toList();
+ bool constantList = constantVariantList(variantList);
+ DBusMessageIter array_iter;
+
+ // List is mapped either as an DBUS array (all items same type)
+ // DBUS struct (variable types) depending on constantList
+ if (constantList) {
+ // Resolve the signature for the first item
+ QString signature = "";
+ if (!variantList.isEmpty()) {
+ signature = variantToSignature(
+ variantList[0],
+ constantVariantList(variantList[0].toList()));
+ }
+
+ // Mapped as DBUS array
+ dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY,
+ signature.toAscii(),
+ &array_iter);
+
+ foreach(QVariant listItem, variantList) {
+ appendVariantToDBusMessage(listItem, &array_iter);
+ }
+
+ dbus_message_iter_close_container(dbus_iter, &array_iter);
+ } else {
+ // Mapped as DBUS struct
+ dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_STRUCT,
+ NULL,
+ &array_iter);
+
+ foreach(QVariant listItem, variantList) {
+ appendVariantToDBusMessage(listItem, &array_iter);
+ }
+
+ dbus_message_iter_close_container(dbus_iter, &array_iter);
+ }
+
+ break;
+ }
+ default:
+ qDebug() << "Unsupported variant type: " << argument.type();
+ break;
+ }
+
+ return true;
+}
+
+static QVariant getVariantFromDBusMessage(DBusMessageIter *iter) {
+ dbus_bool_t bool_data;
+ dbus_int32_t int32_data;
+ dbus_uint32_t uint32_data;
+ dbus_int64_t int64_data;
+ dbus_uint64_t uint64_data;
+ char *str_data;
+ char char_data;
+ int argtype = dbus_message_iter_get_arg_type(iter);
+
+ switch (argtype) {
+
+ case DBUS_TYPE_BOOLEAN:
+ {
+ dbus_message_iter_get_basic(iter, &bool_data);
+ QVariant variant((bool)bool_data);
+ return variant;
+ }
+
+ case DBUS_TYPE_ARRAY:
+ {
+ // Handle all arrays here
+ int elem_type = dbus_message_iter_get_element_type(iter);
+ DBusMessageIter array_iter;
+
+ dbus_message_iter_recurse(iter, &array_iter);
+
+ if (elem_type == DBUS_TYPE_BYTE) {
+ QByteArray byte_array;
+ do {
+ dbus_message_iter_get_basic(&array_iter, &char_data);
+ byte_array.append(char_data);
+ } while (dbus_message_iter_next(&array_iter));
+ QVariant variant(byte_array);
+ return variant;
+ } else if (elem_type == DBUS_TYPE_STRING) {
+ QStringList str_list;
+ do {
+ dbus_message_iter_get_basic(&array_iter, &str_data);
+ str_list.append(str_data);
+ } while (dbus_message_iter_next(&array_iter));
+ QVariant variant(str_list);
+ return variant;
+ } else {
+ QVariantList variantList;
+ do {
+ variantList << getVariantFromDBusMessage(&array_iter);
+ } while (dbus_message_iter_next(&array_iter));
+ QVariant variant(variantList);
+ return variant;
+ }
+ break;
+ }
+
+ case DBUS_TYPE_BYTE:
+ {
+ dbus_message_iter_get_basic(iter, &char_data);
+ QChar ch(char_data);
+ QVariant variant(ch);
+ return variant;
+ }
+
+ case DBUS_TYPE_INT32:
+ {
+ dbus_message_iter_get_basic(iter, &int32_data);
+ QVariant variant((int)int32_data);
+ return variant;
+ }
+
+ case DBUS_TYPE_UINT32:
+ {
+ dbus_message_iter_get_basic(iter, &uint32_data);
+ QVariant variant((uint)uint32_data);
+ return variant;
+ }
+
+ case DBUS_TYPE_STRING:
+ {
+ dbus_message_iter_get_basic(iter, &str_data);
+ QString str(str_data);
+ QVariant variant(str);
+ return variant;
+ }
+
+ case DBUS_TYPE_INT64:
+ {
+ dbus_message_iter_get_basic(iter, &int64_data);
+ QVariant variant((qlonglong)int64_data);
+ return variant;
+ }
+
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_message_iter_get_basic(iter, &uint64_data);
+ QVariant variant((qulonglong)uint64_data);
+ return variant;
+ }
+
+ case DBUS_TYPE_STRUCT:
+ {
+ // Handle all structs here
+ DBusMessageIter struct_iter;
+ dbus_message_iter_recurse(iter, &struct_iter);
+
+ QVariantList variantList;
+ do {
+ variantList << getVariantFromDBusMessage(&struct_iter);
+ } while (dbus_message_iter_next(&struct_iter));
+ QVariant variant(variantList);
+ return variant;
+ }
+
+ default:
+ qDebug() << "Unsupported DBUS type: " << argtype;
+ }
+
+ return QVariant();
+}
+
+static DBusHandlerResult signalHandler (DBusConnection *connection,
+ DBusMessage *message,
+ void *object_ref) {
+ (void)connection;
+ QString interface;
+ QString signal;
+ DBusDispatcher *dispatcher = (DBusDispatcher *)object_ref;
+
+ if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL) {
+ interface = dbus_message_get_interface(message);
+ signal = dbus_message_get_member(message);
+
+ QList<QVariant> arglist;
+ DBusMessageIter dbus_iter;
+
+ if (dbus_message_iter_init(message, &dbus_iter)) {
+ // Read return arguments
+ while (dbus_message_iter_get_arg_type (&dbus_iter) != DBUS_TYPE_INVALID) {
+ arglist << getVariantFromDBusMessage(&dbus_iter);
+ dbus_message_iter_next(&dbus_iter);
+ }
+ }
+
+ dispatcher->emitSignalReceived(interface, signal, arglist);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ (void)message;
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+DBusDispatcher::DBusDispatcher(const QString& service,
+ const QString& path,
+ const QString& interface,
+ QObject *parent)
+ : QObject(parent),
+ d_ptr(new DBusDispatcherPrivate(service, path, interface, path)) {
+ setupDBus();
+}
+
+DBusDispatcher::DBusDispatcher(const QString& service,
+ const QString& path,
+ const QString& interface,
+ const QString& signalPath,
+ QObject *parent)
+ : QObject(parent),
+ d_ptr(new DBusDispatcherPrivate(service, path, interface, signalPath)) {
+ setupDBus();
+}
+
+DBusDispatcher::~DBusDispatcher()
+{
+ if (d_ptr->connection) {
+ dbus_connection_close(d_ptr->connection);
+ dbus_connection_unref(d_ptr->connection);
+ }
+ delete d_ptr;
+}
+
+void DBusDispatcher::setupDBus()
+{
+ d_ptr->connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
+
+ if (d_ptr->connection == NULL)
+ qDebug() << "Unable to get DBUS connection!";
+ else {
+ d_ptr->signal_vtable.message_function = signalHandler;
+
+ dbus_connection_set_exit_on_disconnect(d_ptr->connection, FALSE);
+ dbus_connection_setup_with_g_main(d_ptr->connection, g_main_context_get_thread_default());
+ dbus_connection_register_object_path(d_ptr->connection,
+ d_ptr->signalPath.toLatin1(),
+ &d_ptr->signal_vtable,
+ this);
+ }
+}
+
+static DBusMessage *prepareDBusCall(const QString& service,
+ const QString& path,
+ const QString& interface,
+ const QString& method,
+ const QVariant& arg1 = QVariant(),
+ const QVariant& arg2 = QVariant(),
+ const QVariant& arg3 = QVariant(),
+ const QVariant& arg4 = QVariant(),
+ const QVariant& arg5 = QVariant(),
+ const QVariant& arg6 = QVariant(),
+ const QVariant& arg7 = QVariant(),
+ const QVariant& arg8 = QVariant())
+{
+ DBusMessage *message = dbus_message_new_method_call(service.toLatin1(),
+ path.toLatin1(),
+ interface.toLatin1(),
+ method.toLatin1());
+ DBusMessageIter dbus_iter;
+
+ // Append variants to DBUS message
+ QList<QVariant> arglist;
+ if (arg1.isValid()) arglist << arg1;
+ if (arg2.isValid()) arglist << arg2;
+ if (arg3.isValid()) arglist << arg3;
+ if (arg4.isValid()) arglist << arg4;
+ if (arg5.isValid()) arglist << arg5;
+ if (arg6.isValid()) arglist << arg6;
+ if (arg7.isValid()) arglist << arg7;
+ if (arg8.isValid()) arglist << arg8;
+
+ dbus_message_iter_init_append (message, &dbus_iter);
+
+ while (!arglist.isEmpty()) {
+ QVariant argument = arglist.takeFirst();
+ appendVariantToDBusMessage(argument, &dbus_iter);
+ }
+
+ return message;
+}
+
+QList<QVariant> DBusDispatcher::call(const QString& method,
+ const QVariant& arg1,
+ const QVariant& arg2,
+ const QVariant& arg3,
+ const QVariant& arg4,
+ const QVariant& arg5,
+ const QVariant& arg6,
+ const QVariant& arg7,
+ const QVariant& arg8) {
+ DBusMessageIter dbus_iter;
+ DBusMessage *message = prepareDBusCall(d_ptr->service, d_ptr->path,
+ d_ptr->interface, method,
+ arg1, arg2, arg3, arg4, arg5,
+ arg6, arg7, arg8);
+ DBusMessage *reply = dbus_connection_send_with_reply_and_block(
+ d_ptr->connection,
+ message, -1, NULL);
+ dbus_message_unref(message);
+
+ QList<QVariant> replylist;
+ if (reply != NULL && dbus_message_iter_init(reply, &dbus_iter)) {
+ // Read return arguments
+ while (dbus_message_iter_get_arg_type (&dbus_iter) != DBUS_TYPE_INVALID) {
+ replylist << getVariantFromDBusMessage(&dbus_iter);
+ dbus_message_iter_next(&dbus_iter);
+ }
+ }
+ if (reply != NULL) dbus_message_unref(reply);
+ return replylist;
+}
+
+class PendingCallInfo {
+public:
+ QString method;
+ DBusDispatcher *dispatcher;
+ DBusDispatcherPrivate *priv;
+};
+
+static void freePendingCallInfo(void *memory) {
+ PendingCallInfo *info = (PendingCallInfo *)memory;
+ delete info;
+}
+
+static void pendingCallFunction (DBusPendingCall *pending,
+ void *memory) {
+ PendingCallInfo *info = (PendingCallInfo *)memory;
+ QString errorStr;
+ QList<QVariant> replyList;
+ DBusMessage *reply = dbus_pending_call_steal_reply (pending);
+
+ Q_ASSERT(reply != NULL);
+
+ if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
+ errorStr = dbus_message_get_error_name (reply);
+ } else {
+ DBusMessageIter dbus_iter;
+ dbus_message_iter_init(reply, &dbus_iter);
+ // Read return arguments
+ while (dbus_message_iter_get_arg_type (&dbus_iter) != DBUS_TYPE_INVALID) {
+ replyList << getVariantFromDBusMessage(&dbus_iter);
+ dbus_message_iter_next(&dbus_iter);
+ }
+ }
+
+ info->priv->pending_calls.removeOne(pending);
+ info->dispatcher->emitCallReply(info->method, replyList, errorStr);
+ dbus_message_unref(reply);
+ dbus_pending_call_unref(pending);
+}
+
+bool DBusDispatcher::callAsynchronous(const QString& method,
+ const QVariant& arg1,
+ const QVariant& arg2,
+ const QVariant& arg3,
+ const QVariant& arg4,
+ const QVariant& arg5,
+ const QVariant& arg6,
+ const QVariant& arg7,
+ const QVariant& arg8) {
+ DBusMessage *message = prepareDBusCall(d_ptr->service, d_ptr->path,
+ d_ptr->interface, method,
+ arg1, arg2, arg3, arg4, arg5,
+ arg6, arg7, arg8);
+ DBusPendingCall *call = NULL;
+ dbus_bool_t ret = dbus_connection_send_with_reply(d_ptr->connection,
+ message, &call, -1);
+ PendingCallInfo *info = new PendingCallInfo;
+ info->method = method;
+ info->dispatcher = this;
+ info->priv = d_ptr;
+
+ dbus_pending_call_set_notify(call, pendingCallFunction, info, freePendingCallInfo);
+ d_ptr->pending_calls.append(call);
+ return (bool)ret;
+}
+
+void DBusDispatcher::emitSignalReceived(const QString& interface,
+ const QString& signal,
+ const QList<QVariant>& args) {
+ emit signalReceived(interface, signal, args); }
+
+void DBusDispatcher::emitCallReply(const QString& method,
+ const QList<QVariant>& args,
+ const QString& error) {
+ emit callReply(method, args, error); }
+
+void DBusDispatcher::synchronousDispatch(int timeout_ms)
+{
+ dbus_connection_read_write_dispatch(d_ptr->connection, timeout_ms);
+}
+
+} // Maemo namespace
+
diff --git a/src/plugins/bearer/icd/dbusdispatcher.h b/src/plugins/bearer/icd/dbusdispatcher.h
new file mode 100644
index 0000000000..d14562948d
--- /dev/null
+++ b/src/plugins/bearer/icd/dbusdispatcher.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef DBUSDISPATCHER_H
+#define DBUSDISPATCHER_H
+
+#include <QObject>
+#include <QVariant>
+
+namespace Maemo {
+
+class DBusDispatcherPrivate;
+class DBusDispatcher : public QObject
+{
+ Q_OBJECT
+
+public:
+ DBusDispatcher(const QString& service,
+ const QString& path,
+ const QString& interface,
+ QObject *parent = 0);
+ DBusDispatcher(const QString& service,
+ const QString& path,
+ const QString& interface,
+ const QString& signalPath,
+ QObject *parent = 0);
+ ~DBusDispatcher();
+
+ QList<QVariant> call(const QString& method,
+ const QVariant& arg1 = QVariant(),
+ const QVariant& arg2 = QVariant(),
+ const QVariant& arg3 = QVariant(),
+ const QVariant& arg4 = QVariant(),
+ const QVariant& arg5 = QVariant(),
+ const QVariant& arg6 = QVariant(),
+ const QVariant& arg7 = QVariant(),
+ const QVariant& arg8 = QVariant());
+ bool callAsynchronous(const QString& method,
+ const QVariant& arg1 = QVariant(),
+ const QVariant& arg2 = QVariant(),
+ const QVariant& arg3 = QVariant(),
+ const QVariant& arg4 = QVariant(),
+ const QVariant& arg5 = QVariant(),
+ const QVariant& arg6 = QVariant(),
+ const QVariant& arg7 = QVariant(),
+ const QVariant& arg8 = QVariant());
+ void emitSignalReceived(const QString& interface,
+ const QString& signal,
+ const QList<QVariant>& args);
+ void emitCallReply(const QString& method,
+ const QList<QVariant>& args,
+ const QString& error = "");
+ void synchronousDispatch(int timeout_ms);
+
+Q_SIGNALS:
+ void signalReceived(const QString& interface,
+ const QString& signal,
+ const QList<QVariant>& args);
+ void callReply(const QString& method,
+ const QList<QVariant>& args,
+ const QString& error);
+
+protected:
+ void setupDBus();
+
+private:
+ DBusDispatcherPrivate *d_ptr;
+};
+
+} // Maemo namespace
+
+#endif
diff --git a/src/plugins/bearer/icd/iapconf.cpp b/src/plugins/bearer/icd/iapconf.cpp
new file mode 100644
index 0000000000..128296aec6
--- /dev/null
+++ b/src/plugins/bearer/icd/iapconf.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <conn_settings.h>
+
+#include "iapconf.h"
+
+#define QSTRING_TO_CONST_CSTR(str) \
+ str.toUtf8().constData()
+
+namespace Maemo {
+
+class IAPConfPrivate {
+public:
+ ConnSettings *settings;
+
+ ConnSettingsValue *variantToValue(const QVariant &variant);
+ QVariant valueToVariant(ConnSettingsValue *value);
+};
+
+ConnSettingsValue *IAPConfPrivate::variantToValue(const QVariant &variant)
+{
+ // Convert variant to ConnSettingsValue
+ ConnSettingsValue *value = conn_settings_value_new();
+ if (value == 0) {
+ qWarning("IAPConf: Unable to create new ConnSettingsValue");
+ return 0;
+ }
+
+ switch(variant.type()) {
+
+ case QVariant::Invalid:
+ value->type = CONN_SETTINGS_VALUE_INVALID;
+ break;
+
+ case QVariant::String: {
+ char *valueStr = strdup(QSTRING_TO_CONST_CSTR(variant.toString()));
+ value->type = CONN_SETTINGS_VALUE_STRING;
+ value->value.string_val = valueStr;
+ break;
+ }
+
+ case QVariant::Int:
+ value->type = CONN_SETTINGS_VALUE_INT;
+ value->value.int_val = variant.toInt();
+ break;
+
+ case QMetaType::Float:
+ case QVariant::Double:
+ value->type = CONN_SETTINGS_VALUE_DOUBLE;
+ value->value.double_val = variant.toDouble();
+ break;
+
+ case QVariant::Bool:
+ value->type = CONN_SETTINGS_VALUE_BOOL;
+ value->value.bool_val = variant.toBool() ? 1 : 0;
+ break;
+
+ case QVariant::ByteArray: {
+ QByteArray array = variant.toByteArray();
+ value->type = CONN_SETTINGS_VALUE_BYTE_ARRAY;
+ value->value.byte_array.len = array.size();
+ value->value.byte_array.val = (unsigned char *)malloc(array.size());
+ memcpy(value->value.byte_array.val, array.constData(), array.size());
+ break;
+ }
+
+ case QVariant::List: {
+ QVariantList list = variant.toList();
+ ConnSettingsValue **list_val = (ConnSettingsValue **)malloc(
+ (list.size() + 1) * sizeof(ConnSettingsValue *));
+
+ for (int idx = 0; idx < list.size(); idx++) {
+ list_val[idx] = variantToValue(list.at(idx));
+ }
+ list_val[list.size()] = 0;
+
+ value->type = CONN_SETTINGS_VALUE_LIST;
+ value->value.list_val = list_val;
+ break;
+ }
+
+ default:
+ qWarning("IAPConf: Can not handle QVariant of type %d",
+ variant.type());
+ conn_settings_value_destroy(value);
+ return 0;
+ }
+
+ return value;
+}
+
+QVariant IAPConfPrivate::valueToVariant(ConnSettingsValue *value)
+{
+ if (value == 0 || value->type == CONN_SETTINGS_VALUE_INVALID) {
+ return QVariant();
+ }
+
+ switch(value->type) {
+
+ case CONN_SETTINGS_VALUE_BOOL:
+ return QVariant(value->value.bool_val ? true : false);
+
+ case CONN_SETTINGS_VALUE_STRING:
+ return QVariant(QString(value->value.string_val));
+
+ case CONN_SETTINGS_VALUE_DOUBLE:
+ return QVariant(value->value.double_val);
+
+ case CONN_SETTINGS_VALUE_INT:
+ return QVariant(value->value.int_val);
+
+ case CONN_SETTINGS_VALUE_LIST: {
+ // At least with GConf backend connsettings returns byte array as list
+ // of ints, first check for that case
+ if (value->value.list_val && value->value.list_val[0]) {
+ bool canBeConvertedToByteArray = true;
+ for (int idx = 0; value->value.list_val[idx]; idx++) {
+ ConnSettingsValue *val = value->value.list_val[idx];
+ if (val->type != CONN_SETTINGS_VALUE_INT
+ || val->value.int_val > 255
+ || val->value.int_val < 0) {
+ canBeConvertedToByteArray = false;
+ break;
+ }
+ }
+
+ if (canBeConvertedToByteArray) {
+ QByteArray array;
+ for (int idx = 0; value->value.list_val[idx]; idx++) {
+ array.append(value->value.list_val[idx]->value.int_val);
+ }
+ return array;
+ }
+
+ // Create normal list
+ QVariantList list;
+ for (int idx = 0; value->value.list_val[idx]; idx++) {
+ list.append(valueToVariant(value->value.list_val[idx]));
+ }
+ return list;
+ }
+ }
+
+ case CONN_SETTINGS_VALUE_BYTE_ARRAY:
+ return QByteArray::fromRawData((char *)value->value.byte_array.val,
+ value->value.byte_array.len);
+
+ default:
+ return QVariant();
+ }
+}
+
+// Public class implementation
+
+IAPConf::IAPConf(const QString &iap_id)
+ : d_ptr(new IAPConfPrivate)
+{
+ d_ptr->settings = conn_settings_open(CONN_SETTINGS_CONNECTION,
+ QSTRING_TO_CONST_CSTR(iap_id));
+ if (d_ptr->settings == 0) {
+ qWarning("IAPConf: Unable to open ConnSettings for %s",
+ QSTRING_TO_CONST_CSTR(iap_id));
+ }
+}
+
+IAPConf::~IAPConf()
+{
+ conn_settings_close(d_ptr->settings);
+ delete d_ptr;
+}
+
+
+QVariant IAPConf::value(const QString& key) const
+{
+ ConnSettingsValue *val = conn_settings_get(d_ptr->settings,
+ QSTRING_TO_CONST_CSTR(key));
+
+ QVariant variant = d_ptr->valueToVariant(val);
+ conn_settings_value_destroy(val);
+ return variant;
+}
+
+
+void IAPConf::getAll(QList<QString> &all_iaps, bool return_path)
+{
+ Q_UNUSED(return_path); // We don't use return path currently
+
+ // Go through all available connections and add them to the list
+ char **ids = conn_settings_list_ids(CONN_SETTINGS_CONNECTION);
+ if (ids == 0) {
+ // No ids found - nothing to do
+ return;
+ }
+
+ for (int idx = 0; ids[idx]; idx++) {
+ all_iaps.append(QString(ids[idx]));
+ free(ids[idx]);
+ }
+ free(ids);
+}
+
+
+} // namespace Maemo
diff --git a/src/plugins/bearer/icd/iapconf.h b/src/plugins/bearer/icd/iapconf.h
new file mode 100644
index 0000000000..909818a8e0
--- /dev/null
+++ b/src/plugins/bearer/icd/iapconf.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef IAPCONF_H
+#define IAPCONF_H
+
+#include <QString>
+#include <QVariant>
+
+namespace Maemo {
+
+class IAPConfPrivate;
+class IAPConf {
+public:
+ IAPConf(const QString &iap_id);
+ virtual ~IAPConf();
+
+ /**
+ Get one IAP value.
+ */
+ QVariant value(const QString& key) const;
+
+ /**
+ Return all the IAPs found in the system. If return_path is true,
+ then do not strip the IAP path away.
+ */
+ static void getAll(QList<QString> &all_iaps, bool return_path=false);
+
+private:
+ IAPConfPrivate *d_ptr;
+};
+
+} // namespace Maemo
+
+#endif
diff --git a/src/plugins/bearer/icd/iapmonitor.cpp b/src/plugins/bearer/icd/iapmonitor.cpp
new file mode 100644
index 0000000000..b2508cdd76
--- /dev/null
+++ b/src/plugins/bearer/icd/iapmonitor.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QStringList>
+
+#include <conn_settings.h>
+#include "iapmonitor.h"
+
+namespace Maemo {
+
+
+void conn_settings_notify_func (ConnSettingsType type,
+ const char *id,
+ const char *key,
+ ConnSettingsValue *value,
+ void *user_data);
+
+class IAPMonitorPrivate {
+private:
+ IAPMonitor *monitor;
+ ConnSettings *settings;
+
+public:
+
+ IAPMonitorPrivate(IAPMonitor *monitor)
+ : monitor(monitor)
+ {
+ settings = conn_settings_open(CONN_SETTINGS_CONNECTION, NULL);
+ conn_settings_add_notify(
+ settings,
+ (ConnSettingsNotifyFunc *)conn_settings_notify_func,
+ this);
+ }
+
+ ~IAPMonitorPrivate()
+ {
+ conn_settings_del_notify(settings);
+ conn_settings_close(settings);
+ }
+
+ void iapAdded(const QString &iap)
+ {
+ monitor->iapAdded(iap);
+ }
+
+ void iapRemoved(const QString &iap)
+ {
+ monitor->iapRemoved(iap);
+ }
+};
+
+void conn_settings_notify_func (ConnSettingsType type,
+ const char *id,
+ const char *key,
+ ConnSettingsValue *value,
+ void *user_data)
+{
+ Q_UNUSED(id);
+
+ if (type != CONN_SETTINGS_CONNECTION) return;
+ IAPMonitorPrivate *priv = (IAPMonitorPrivate *)user_data;
+
+ QString iapId(key);
+ iapId = iapId.split("/")[0];
+ if (value != 0) {
+ priv->iapAdded(iapId);
+ } else if (iapId == QString(key)) {
+ // IAP is removed only when the directory gets removed
+ priv->iapRemoved(iapId);
+ }
+}
+
+IAPMonitor::IAPMonitor()
+ : d_ptr(new IAPMonitorPrivate(this))
+{
+}
+
+IAPMonitor::~IAPMonitor()
+{
+ delete d_ptr;
+}
+
+void IAPMonitor::iapAdded(const QString &id)
+{
+ Q_UNUSED(id);
+ // By default do nothing
+}
+
+void IAPMonitor::iapRemoved(const QString &id)
+{
+ Q_UNUSED(id);
+ // By default do nothing
+}
+
+} // namespace Maemo
diff --git a/src/plugins/bearer/icd/iapmonitor.h b/src/plugins/bearer/icd/iapmonitor.h
new file mode 100644
index 0000000000..cb8135de58
--- /dev/null
+++ b/src/plugins/bearer/icd/iapmonitor.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef IAPMONITOR_H
+#define IAPMONITOR_H
+
+#include <QString>
+
+namespace Maemo {
+
+class IAPMonitorPrivate;
+class IAPMonitor {
+public:
+ IAPMonitor();
+ ~IAPMonitor();
+
+protected:
+ virtual void iapAdded(const QString &id);
+ virtual void iapRemoved(const QString &id);
+
+private:
+ IAPMonitorPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(IAPMonitor);
+};
+
+} // namespace Maemo
+
+#endif // IAPMONITOR_H
+
diff --git a/src/plugins/bearer/icd/icd.pro b/src/plugins/bearer/icd/icd.pro
new file mode 100644
index 0000000000..6700cdaaa8
--- /dev/null
+++ b/src/plugins/bearer/icd/icd.pro
@@ -0,0 +1,33 @@
+TARGET = qicdbearer
+include(../../qpluginbase.pri)
+
+QT = core network dbus
+
+QMAKE_CXXFLAGS *= $$QT_CFLAGS_DBUS $$QT_CFLAGS_CONNSETTINGS
+LIBS += $$QT_LIBS_CONNSETTINGS
+
+HEADERS += qicdengine.h \
+ qnetworksession_impl.h \
+ dbusdispatcher.h \
+ iapconf.h \
+ iapmonitor.h \
+ maemo_icd.h \
+ proxyconf.h \
+ wlan-utils.h
+
+SOURCES += main.cpp \
+ qicdengine.cpp \
+ qnetworksession_impl.cpp \
+ dbusdispatcher.cpp \
+ iapmonitor.cpp \
+ iapconf.cpp \
+ maemo_icd.cpp \
+ proxyconf.cpp
+
+#DEFINES += BEARER_MANAGEMENT_DEBUG
+
+include(../../../3rdparty/libgq.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
+target.path += $$[QT_INSTALL_PLUGINS]/bearer
+INSTALLS += target
diff --git a/src/plugins/bearer/icd/maemo_icd.cpp b/src/plugins/bearer/icd/maemo_icd.cpp
new file mode 100644
index 0000000000..1a27f0905b
--- /dev/null
+++ b/src/plugins/bearer/icd/maemo_icd.cpp
@@ -0,0 +1,855 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "maemo_icd.h"
+#include "dbusdispatcher.h"
+
+#include <QObject>
+#include <QTimer>
+#include <QCoreApplication>
+#include <QEventLoop>
+#include <QDebug>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+namespace Maemo {
+
+#undef PRINT_DEBUGINFO
+#ifdef PRINT_DEBUGINFO
+ static FILE *fdebug = NULL;
+#define PDEBUG(fmt, args...) \
+ do { \
+ struct timeval tv; \
+ gettimeofday(&tv, 0); \
+ fprintf(fdebug, "DEBUG[%d]:%ld.%ld:%s:%s():%d: " fmt, \
+ getpid(), \
+ tv.tv_sec, tv.tv_usec, \
+ __FILE__, __FUNCTION__, __LINE__, args); \
+ fflush(fdebug); \
+ } while(0)
+#else
+#define PDEBUG(fmt...)
+#endif
+
+
+class IcdPrivate
+{
+public:
+ IcdPrivate(Icd *myfriend)
+ {
+ init(10000, IcdNewDbusInterface, myfriend);
+ }
+
+ IcdPrivate(unsigned int timeout, Icd *myfriend)
+ {
+ init(timeout, IcdNewDbusInterface, myfriend);
+ }
+
+ IcdPrivate(unsigned int timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
+ {
+ Q_UNUSED(ver);
+
+ /* Note that the old Icd interface is currently disabled and
+ * the new one is always used.
+ */
+ init(timeout, IcdNewDbusInterface, myfriend);
+ }
+
+ ~IcdPrivate()
+ {
+ QObject::disconnect(mDBus,
+ SIGNAL(signalReceived(const QString&,
+ const QString&,
+ const QList<QVariant>&)),
+ icd,
+ SLOT(icdSignalReceived(const QString&,
+ const QString&,
+ const QList<QVariant>&)));
+
+ QObject::disconnect(mDBus,
+ SIGNAL(callReply(const QString&,
+ const QList<QVariant>&,
+ const QString&)),
+ icd,
+ SLOT(icdCallReply(const QString&,
+ const QList<QVariant>&,
+ const QString&)));
+
+ delete mDBus;
+ mDBus = 0;
+ }
+
+ /* Icd2 dbus API functions */
+ QStringList scan(icd_scan_request_flags flags,
+ QStringList &network_types,
+ QList<IcdScanResult>& scan_results,
+ QString& error);
+
+ uint state(QString& service_type, uint service_attrs,
+ QString& service_id, QString& network_type,
+ uint network_attrs, QByteArray& network_id,
+ IcdStateResult &state_result);
+
+ uint addrinfo(QString& service_type, uint service_attrs,
+ QString& service_id, QString& network_type,
+ uint network_attrs, QByteArray& network_id,
+ IcdAddressInfoResult& addr_result);
+
+ uint state(QList<IcdStateResult>& state_results);
+ uint statistics(QList<IcdStatisticsResult>& stats_results);
+ uint addrinfo(QList<IcdAddressInfoResult>& addr_results);
+
+ void signalReceived(const QString& interface,
+ const QString& signal,
+ const QList<QVariant>& args);
+ void callReply(const QString& method,
+ const QList<QVariant>& args,
+ const QString& error);
+
+public:
+ DBusDispatcher *mDBus;