~ubuntu-branches/ubuntu/quantal/virtualbox/quantal

« back to all changes in this revision

Viewing changes to src/VBox/Main/src-client/ConsoleImpl.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-05 12:41:55 UTC
  • mfrom: (3.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120405124155-i7b39tv5ddwhubbe
Tags: 4.1.12-dfsg-2
* Upstream has replaced the 4.1.12 tarball with a new one that fixes a
  crash when creating host only interfaces. (Closes: #667460)
  - Add 36-tarball-respin.patch which contains the diff between the old
    and the new tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
752
752
    if (!guestPropertiesVRDPEnabled())
753
753
        return;
754
754
 
 
755
    LogFlowFunc(("\n"));
 
756
 
755
757
    char szPropNm[256];
756
758
    Bstr bstrReadOnlyGuest(L"RDONLYGUEST");
757
759
 
774
776
                               bstrReadOnlyGuest.raw());
775
777
 
776
778
    char szClientId[64];
777
 
    RTStrPrintf(szClientId, sizeof(szClientId), "%d", u32ClientId);
 
779
    RTStrPrintf(szClientId, sizeof(szClientId), "%u", u32ClientId);
778
780
    mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastConnectedClient").raw(),
779
781
                               Bstr(szClientId).raw(),
780
782
                               bstrReadOnlyGuest.raw());
782
784
    return;
783
785
}
784
786
 
 
787
void Console::guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId)
 
788
{
 
789
    if (!guestPropertiesVRDPEnabled())
 
790
        return;
 
791
 
 
792
    LogFlowFunc(("%d\n", u32ClientId));
 
793
 
 
794
    Bstr bstrFlags(L"RDONLYGUEST,TRANSIENT");
 
795
 
 
796
    char szClientId[64];
 
797
    RTStrPrintf(szClientId, sizeof(szClientId), "%u", u32ClientId);
 
798
 
 
799
    mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/ActiveClient").raw(),
 
800
                               Bstr(szClientId).raw(),
 
801
                               bstrFlags.raw());
 
802
 
 
803
    return;
 
804
}
 
805
 
 
806
void Console::guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName)
 
807
{
 
808
    if (!guestPropertiesVRDPEnabled())
 
809
        return;
 
810
 
 
811
    LogFlowFunc(("\n"));
 
812
 
 
813
    char szPropNm[256];
 
814
    Bstr bstrReadOnlyGuest(L"RDONLYGUEST");
 
815
 
 
816
    RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
 
817
    Bstr clientName(pszName);
 
818
 
 
819
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(),
 
820
                               clientName.raw(),
 
821
                               bstrReadOnlyGuest.raw());
 
822
 
 
823
}
 
824
 
 
825
void Console::guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached)
 
826
{
 
827
    if (!guestPropertiesVRDPEnabled())
 
828
        return;
 
829
 
 
830
    LogFlowFunc(("\n"));
 
831
 
 
832
    Bstr bstrReadOnlyGuest(L"RDONLYGUEST");
 
833
 
 
834
    char szPropNm[256];
 
835
    RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Attach", u32ClientId);
 
836
 
 
837
    Bstr bstrValue = fAttached? "1": "0";
 
838
 
 
839
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(),
 
840
                               bstrValue.raw(),
 
841
                               bstrReadOnlyGuest.raw());
 
842
}
 
843
 
785
844
void Console::guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId)
786
845
{
787
846
    if (!guestPropertiesVRDPEnabled())
788
847
        return;
789
848
 
 
849
    LogFlowFunc(("\n"));
 
850
 
790
851
    Bstr bstrReadOnlyGuest(L"RDONLYGUEST");
791
852
 
792
853
    char szPropNm[256];
793
854
    RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
794
 
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), Bstr("").raw(),
 
855
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
795
856
                               bstrReadOnlyGuest.raw());
796
857
 
797
858
    RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
798
 
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), Bstr("").raw(),
 
859
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
799
860
                               bstrReadOnlyGuest.raw());
800
861
 
801
862
    RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
802
 
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), Bstr("").raw(),
 
863
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
 
864
                               bstrReadOnlyGuest.raw());
 
865
 
 
866
    RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Attach", u32ClientId);
 
867
    mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
803
868
                               bstrReadOnlyGuest.raw());
804
869
 
805
870
    char szClientId[64];
1061
1126
    return VINF_SUCCESS;
1062
1127
}
1063
1128
 
 
1129
void Console::VRDPClientStatusChange(uint32_t u32ClientId, const char *pszStatus)
 
1130
{
 
1131
    LogFlowFuncEnter();
 
1132
 
 
1133
    AutoCaller autoCaller(this);
 
1134
    AssertComRCReturnVoid(autoCaller.rc());
 
1135
 
 
1136
    LogFlowFunc(("%s\n", pszStatus));
 
1137
 
 
1138
    /* Parse the status string. */
 
1139
    if (RTStrICmp(pszStatus, "ATTACH") == 0)
 
1140
    {
 
1141
        guestPropertiesVRDPUpdateClientAttach(u32ClientId, true);
 
1142
    }
 
1143
    else if (RTStrICmp(pszStatus, "DETACH") == 0)
 
1144
    {
 
1145
        guestPropertiesVRDPUpdateClientAttach(u32ClientId, false);
 
1146
    }
 
1147
    else if (RTStrNICmp(pszStatus, "NAME=", strlen("NAME=")) == 0)
 
1148
    {
 
1149
        guestPropertiesVRDPUpdateNameChange(u32ClientId, pszStatus + strlen("NAME="));
 
1150
    }
 
1151
 
 
1152
    LogFlowFuncLeave();
 
1153
}
 
1154
 
1064
1155
void Console::VRDPClientConnect(uint32_t u32ClientId)
1065
1156
{
1066
1157
    LogFlowFuncEnter();
1084
1175
    NOREF(u32ClientId);
1085
1176
    mDisplay->VideoAccelVRDP(true);
1086
1177
 
 
1178
#ifdef VBOX_WITH_GUEST_PROPS
 
1179
    guestPropertiesVRDPUpdateActiveClient(u32ClientId);
 
1180
#endif /* VBOX_WITH_GUEST_PROPS */
 
1181
 
1087
1182
    LogFlowFuncLeave();
1088
1183
    return;
1089
1184
}
1154
1249
 
1155
1250
#ifdef VBOX_WITH_GUEST_PROPS
1156
1251
    guestPropertiesVRDPUpdateDisconnect(u32ClientId);
 
1252
    if (u32Clients == 0)
 
1253
        guestPropertiesVRDPUpdateActiveClient(0);
1157
1254
#endif /* VBOX_WITH_GUEST_PROPS */
1158
1255
 
1159
1256
    if (u32Clients == 0)
1828
1925
 
1829
1926
    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1830
1927
 
1831
 
    mfUseHostClipboard = aUseHostClipboard;
 
1928
    mfUseHostClipboard = !!aUseHostClipboard;
1832
1929
 
1833
1930
    return S_OK;
1834
1931
}
2996
3093
    rc = pSharedFolder->init(this,
2997
3094
                             strName,
2998
3095
                             strHostPath,
2999
 
                             aWritable,
3000
 
                             aAutoMount,
 
3096
                             !!aWritable,
 
3097
                             !!aAutoMount,
3001
3098
                             true /* fFailOnError */);
3002
3099
    if (FAILED(rc)) return rc;
3003
3100
 
3019
3116
        }
3020
3117
 
3021
3118
        /* second, create the given folder */
3022
 
        rc = createSharedFolder(aName, SharedFolderData(aHostPath, aWritable, aAutoMount));
 
3119
        rc = createSharedFolder(aName, SharedFolderData(aHostPath, !!aWritable, !!aAutoMount));
3023
3120
        if (FAILED(rc))
3024
3121
            return rc;
3025
3122
    }
4360
4457
                break;
4361
4458
 
4362
4459
            bool fUdp = aProto == NATProtocol_UDP;
4363
 
            vrc = pNetNatCfg->pfnRedirectRuleCommand(pNetNatCfg, aNatRuleRemove, fUdp,
 
4460
            vrc = pNetNatCfg->pfnRedirectRuleCommand(pNetNatCfg, !!aNatRuleRemove, fUdp,
4364
4461
                                                     Utf8Str(aHostIp).c_str(), aHostPort, Utf8Str(aGuestIp).c_str(),
4365
4462
                                                     aGuestPort);
4366
4463
            if (RT_FAILURE(vrc))
7012
7109
                if (FAILED(rc)) throw rc;
7013
7110
 
7014
7111
                m_mapMachineSharedFolders.insert(std::make_pair(strName,
7015
 
                                                                SharedFolderData(strHostPath, writable, autoMount)));
 
7112
                                                                SharedFolderData(strHostPath, !!writable, !!autoMount)));
7016
7113
 
7017
7114
                /* send changes to HGCM if the VM is running */
7018
7115
                if (online)
7039
7136
 
7040
7137
                            /* create the new machine folder */
7041
7138
                            rc = createSharedFolder(strName,
7042
 
                                                    SharedFolderData(strHostPath,
7043
 
                                                                     writable,
7044
 
                                                                     autoMount));
 
7139
                                                    SharedFolderData(strHostPath, !!writable, !!autoMount));
7045
7140
                            if (FAILED(rc)) throw rc;
7046
7141
                        }
7047
7142
                    }