Changeset 78666 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- May 22, 2019 3:27:27 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130737
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r78234 r78666 396 396 } 397 397 398 /* static */ 399 Utf8Str GuestFile::i_guestErrorToString(int rcGuest) 400 { 401 Utf8Str strError; 402 398 /* static */ const char *GuestFile::i_guestVrcToString(int rcGuest) 399 { 403 400 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 404 401 switch (rcGuest) 405 402 { 406 case VERR_ACCESS_DENIED: 407 strError += Utf8StrFmt(tr("Access denied")); 408 break; 409 410 case VERR_ALREADY_EXISTS: 411 strError += Utf8StrFmt(tr("File already exists")); 412 break; 413 414 case VERR_FILE_NOT_FOUND: 415 strError += Utf8StrFmt(tr("File not found")); 416 break; 417 418 case VERR_NET_HOST_NOT_FOUND: 419 strError += Utf8StrFmt(tr("Host name not found")); 420 break; 421 422 case VERR_SHARING_VIOLATION: 423 strError += Utf8StrFmt(tr("Sharing violation")); 424 break; 425 426 default: 427 strError += Utf8StrFmt("%Rrc", rcGuest); 428 break; 429 } 430 431 return strError; 403 case VERR_ACCESS_DENIED: return tr("Access denied"); 404 case VERR_ALREADY_EXISTS: return tr("File already exists"); 405 case VERR_FILE_NOT_FOUND: return tr("File not found"); 406 case VERR_NET_HOST_NOT_FOUND: return tr("Host name not found"); 407 case VERR_SHARING_VIOLATION: return tr("Sharing violation"); 408 default: return RTErrGetDefine(rcGuest); 409 } 410 } 411 412 /** 413 * @todo r=bird: This is an absolutely cryptic way of reporting errors. You may convert 414 * this to a const char * returning function for explaining rcGuest and 415 * use that as part of a _proper_ error message. This alone extremely 416 * user unfriendly. E.g. which file is not found? One of the source files, 417 * a destination file, what are you referring to?!? 418 * 419 * I've addressed one of these that annoyed me, you can do the rest of them. 420 */ 421 /* static */ Utf8Str GuestFile::i_guestErrorToString(int rcGuest) 422 { 423 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 424 return i_guestVrcToString(rcGuest); 432 425 } 433 426 -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r78234 r78666 793 793 794 794 /* Validate stuff. */ 795 if (RT_UNLIKELY(SourceSet.size() == 0 || *(SourceSet[0].strSource.c_str()) == '\0')) /* At least one source must be present. */ 796 return setError(E_INVALIDARG, tr("No source(s) specified")); 797 if (RT_UNLIKELY((strDestination.c_str()) == NULL || *(strDestination.c_str()) == '\0')) 795 /** @todo r=bird: these validations are better left to the caller. The first one in particular as there is only one 796 * of the four callers which supplies a user specified source set, making an assertion more appropriate and efficient 797 * here. */ 798 if (RT_UNLIKELY(SourceSet.size() == 0)) /* At least one source must be present. */ 799 return setError(E_INVALIDARG, tr("No sources specified")); 800 if (RT_UNLIKELY(SourceSet[0].strSource.isEmpty())) 801 return setError(E_INVALIDARG, tr("First source entry is empty")); 802 if (RT_UNLIKELY(strDestination.isEmpty())) 798 803 return setError(E_INVALIDARG, tr("No destination specified")); 799 804 … … 3027 3032 GuestSessionFsSourceSet SourceSet; 3028 3033 3034 /** @todo r=bird: The GuestSessionFsSourceSpec constructor does not zero the 3035 * members you aren't setting here and there are no hints about "input" 3036 * vs "task" members, so you have me worrying about using random stack by 3037 * accident somewhere... For instance Type.File.phFile sure sounds like 3038 * an input field and thus a disaster waiting to happen. */ 3029 3039 GuestSessionFsSourceSpec source; 3030 3040 source.strSource = aSource; -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r77531 r78666 208 208 COM_IIDOF(IGuestSession), 209 209 GuestSession::getStaticComponentName(), 210 /** @todo r=bird: i_notifyComplete takes a format string, so this is 211 * potentially risky business if a user input mentioned by the message 212 * text contains '%s'! With code below for how to do this less 213 * painfully and with fewer string copies. */ 210 214 strMsg.c_str()); 211 215 if (FAILED(hr2)) … … 213 217 } 214 218 return hr; /* Return original rc. */ 219 } 220 221 HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hrc, int vrc, const char *pszFormat, ...) 222 { 223 LogFlowFunc(("hrc=%Rhrc, vrc=%Rrc, pszFormat=%s\n", hrc, vrc, pszFormat)); 224 225 /* The progress object is optional. */ 226 if (!mProgress.isNull()) 227 { 228 BOOL fCanceled; 229 BOOL fCompleted; 230 if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled))) 231 && !fCanceled 232 && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted))) 233 && !fCompleted) 234 { 235 va_list va; 236 va_start(va, pszFormat); 237 HRESULT hrc2 = mProgress->i_notifyCompleteBothV(hrc, vrc, COM_IIDOF(IGuestSession), 238 GuestSession::getStaticComponentName(), pszFormat, va); 239 va_end(va); 240 if (FAILED(hrc2)) 241 hrc = hrc2; 242 } 243 } 244 return hrc; 215 245 } 216 246 … … 763 793 int rcGuest = VERR_IPE_UNINITIALIZED_STATUS; 764 794 int rc = mSession->i_fsQueryInfo(strDest, TRUE /* fFollowSymlinks */, dstObjData, &rcGuest); 765 if (RT_FAILURE(rc)) 766 { 767 switch (rc) 768 { 769 case VERR_GSTCTL_GUEST_ERROR: 770 if (rcGuest == VERR_FILE_NOT_FOUND) /* File might not exist on the guest yet. */ 771 { 772 rc = VINF_SUCCESS; 773 } 774 else 775 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest)); 776 break; 777 778 default: 779 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 780 Utf8StrFmt(GuestSession::tr("Destination file lookup for \"%s\" failed: %Rrc"), 781 strDest.c_str(), rc)); 782 break; 783 } 795 if (rc == VERR_GSTCTL_GUEST_ERROR && rcGuest == VERR_FILE_NOT_FOUND) /* File might not exist on the guest yet. */ 796 rc = VINF_SUCCESS; 797 else if (RT_FAILURE(rc)) 798 { 799 setProgressErrorMsg(VBOX_E_IPRT_ERROR, rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc, 800 GuestSession::tr("Destination file lookup for \"%s\" failed: %Rrc"), 801 strDest.c_str(), rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc); 802 return rc; 784 803 } 785 804 else … … 791 810 /* Build the final file name with destination path (on the host). */ 792 811 char szDstPath[RTPATH_MAX]; 812 /** @todo r=bird: WTF IS THIS SUPPOSED TO BE?!? Use RTStrCopy, memcpy, or similar! 813 * Ever thought about modifying strDestFinal (it's 'Dst' not 'Dest' btw.) 814 * directly? There are any number of append and insert methods in the 815 * RTCString/Utf8Str class for doing that! */ 793 816 RTStrPrintf2(szDstPath, sizeof(szDstPath), "%s", strDest.c_str()); 794 817 818 /** @todo r=bird: You're totally ignoring the guest slash-style here! Callers 819 * should have this info. */ 795 820 if ( !strDest.endsWith("\\") 796 821 && !strDest.endsWith("/")) … … 848 873 if (RT_FAILURE(rc)) 849 874 { 850 switch (rc) 851 { 852 case VERR_GSTCTL_GUEST_ERROR: 853 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest)); 854 break; 855 856 default: 857 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 858 Utf8StrFmt(GuestSession::tr("Destination file \"%s\" could not be opened: %Rrc"), 859 strDestFinal.c_str(), rc)); 860 break; 861 } 862 } 863 864 if (RT_FAILURE(rc)) 875 setProgressErrorMsg(VBOX_E_IPRT_ERROR, rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc, 876 GuestSession::tr("Destination file \"%s\" could not be opened: %Rrc"), 877 strDestFinal.c_str(), rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc); 865 878 return rc; 879 } 866 880 867 881 char szSrcReal[RTPATH_MAX]; … … 1383 1397 } 1384 1398 1385 GuestSessionTaskCopyFrom::GuestSessionTaskCopyFrom(GuestSession *pSession, GuestSessionFsSourceSet vecSrc, const Utf8Str &strDest) 1386 : GuestSessionCopyTask(pSession) 1399 GuestSessionTaskCopyFrom::GuestSessionTaskCopyFrom(GuestSession *pSession, GuestSessionFsSourceSet const &vecSrc, 1400 const Utf8Str &strDest) 1401 : GuestSessionCopyTask(pSession) 1387 1402 { 1388 1403 m_strTaskName = "gctlCpyFrm"; … … 1629 1644 } 1630 1645 1631 GuestSessionTaskCopyTo::GuestSessionTaskCopyTo(GuestSession *pSession, GuestSessionFsSourceSet vecSrc, const Utf8Str &strDest) 1632 : GuestSessionCopyTask(pSession) 1646 GuestSessionTaskCopyTo::GuestSessionTaskCopyTo(GuestSession *pSession, GuestSessionFsSourceSet const &vecSrc, 1647 const Utf8Str &strDest) 1648 : GuestSessionCopyTask(pSession) 1633 1649 { 1634 1650 m_strTaskName = "gctlCpyTo"; … … 1801 1817 if (pList->mSourceSpec.enmType == FsObjType_Directory) 1802 1818 { 1803 fCopyIntoExisting = pList->mSourceSpec.Type.Dir.fCopyFlags & DirectoryCopyFlag_CopyIntoExisting;1819 fCopyIntoExisting = RT_BOOL(pList->mSourceSpec.Type.Dir.fCopyFlags & DirectoryCopyFlag_CopyIntoExisting); 1804 1820 fFollowSymlinks = pList->mSourceSpec.Type.Dir.fFollowSymlinks; 1805 1821 … … 1814 1830 else if (pList->mSourceSpec.enmType == FsObjType_File) 1815 1831 { 1816 fCopyIntoExisting = ! RT_BOOL(pList->mSourceSpec.Type.File.fCopyFlags & FileCopyFlag_NoReplace);1832 fCopyIntoExisting = !(pList->mSourceSpec.Type.File.fCopyFlags & FileCopyFlag_NoReplace); 1817 1833 fFollowSymlinks = RT_BOOL(pList->mSourceSpec.Type.File.fCopyFlags & FileCopyFlag_FollowLinks); 1818 1834 } … … 1937 1953 1938 1954 int GuestSessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, RTVFS hVfsIso, 1939 Utf8Str const &strFileSource, const Utf8Str &strFileDest,1940 bool fOptional)1955 Utf8Str const &strFileSource, const Utf8Str &strFileDest, 1956 bool fOptional) 1941 1957 { 1942 1958 AssertPtrReturn(pSession, VERR_INVALID_POINTER);
Note:
See TracChangeset
for help on using the changeset viewer.