1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /**
- * Copyright (c) 2012 Nokia Corporation.
- */
- import QtQuick 1.1
- import com.nokia.meego 1.1
- import ConnectivityPlugin 1.0
- PageStackWindow {
- id: root
- showStatusBar: true
- showToolBar: true
- initialPage: Qt.resolvedUrl("MainPage.qml")
- Component.onCompleted: {
- theme.inverted = true
- }
- ListModel {
- id: discoveredServicesModel
- }
- // For storing chatmessages
- ListModel {
- id: myMessageModel
- }
- ConnectionManager {
- id: connectionManager
- maxConnections: 1
- property int prevStatus: ConnectionManager.NotConnected;
- property bool isBluetooth: (connectionManager.connectionType == ConnectionManager.Bluetooth);
- property bool isLAN : (connectionManager.connectionType == ConnectionManager.LAN);
- property bool isConnected: (connectionManager.status == ConnectionManager.Connected);
- onErrorChanged: {
- console.debug("ConnectionManager::onErrorChanged " + errorString)
- }
- onNetworkStatusChanged: {
- console.debug("ConnectionManager::networkStatus changed to " + networkStatus)
- }
- onStatusChanged: {
- console.debug("ConnectionManager::status changed to " + status);
- console.debug("ConnectionManager::prevStatus was " + connectionManager.prevStatus);
- if (status == ConnectionManager.Discovering) {
- var connectionTypeOk = connectionManager.isBluetooth || connectionManager.isLAN;
- var connectAsOk =
- (connectionManager.connectAs == ConnectionManager.Client) ||
- (connectionManager.connectAs == ConnectionManager.DontCare);
- if (connectionTypeOk && connectAsOk)
- {
- pageStack.push(Qt.resolvedUrl("DiscoveryPage.qml"));
- }
- }
- //If connectAs is DontCare and someone connects to us while
- //we are at discovery screen, we'll pop it back.
- if (status == ConnectionManager.Connected &&
- connectionManager.prevStatus == ConnectionManager.Discovering &&
- connectionManager.connectAs == ConnectionManager.DontCare)
- {
- pageStack.pop();
- }
- connectionManager.prevStatus = status;
- }
- onConnectionTypeChanged: {
- //When connection type changed we'll clear the servicesModel
- discoveredServicesModel.clear();
- }
- onDiscovered: {
- discoveredServicesModel.append({name : name});
- }
- onRemoved: {
- discoveredServicesModel.remove(index);
- }
- onReceived: {
- myMessageModel.append({"message": message, "me": false,
- "metaString": Qt.formatDateTime(new Date(),
- "hh:mm | dd.MM.yyyy")})
- }
- }
- }
|