/** \brief MouseUp Callback. * This handles the situation where someone does a drag and drop of an item. * In this case we should copy it to the desired location. * * \todo Implement recursive transfer when a folder is dropped. */ void RemoteIconView::MouseUp( const Point& cPoint, uint32 nButtons, Message* pcData ) { if( pcData == NULL || m_pcServer == NULL ) { /* No drag & drop, or no connection */ IconView::MouseUp( cPoint, nButtons, pcData ); return; } StopScroll(); /* We got a drag & drop. Check if it contains a local file */ int nCount, nType; pcData->GetNameInfo( "file/path", &nType, &nCount ); if( nType != T_STRING || nCount == 0 ) { /* Something was dropped that isn't a file. Ignore it */ IconView::MouseUp( cPoint, nButtons, pcData ); return; } /* Check if there is a directory icon under the mouse. If so, we transfer the file into that directory. Otherwise, we transfer it into this directory. */ String zDestPath = m_zPath; for( uint i = 0; i < GetIconCount(); i++ ) { if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( ConvertToView( cPoint ) ) ) { /* Found an icon under the mouse */ RemoteIconData* pcData = (RemoteIconData*)GetIconData( i ); if( pcData->m_cNode.IsDir() ) { /* Found a dir under the mouse. Add it to the destination path */ zDestPath += "/"; zDestPath += pcData->m_cNode.m_zName; break; } } } /* Start transferring the files */ String zSource; String zDest; for( int i = 0; pcData->FindString( "file/path", &zSource, i ) == 0; i++ ) { Path cPath( zSource ); zDest = zDestPath; if( zDest.Length() > 0 && zDest[zDest.Length()-1] != '/' ) zDest += "/"; zDest += cPath.GetLeaf(); DEBUG( "GUI: Drag & drop %s to %s\n", zSource.c_str(), zDest.c_str() ); /* Ask the Server object to start the transfer */ /* Need to determine if it is a file or a dir first though */ FileReference cFileRef( zSource ); struct stat sStat; cFileRef.GetStat( &sStat ); if( S_ISDIR( sStat.st_mode ) ) { m_pcServer->SendLocalDir( zSource, zDest ); } else { m_pcServer->SendLocalFile( zSource, zDest ); } } }
HRESULT FakeContactsServiceContent::GetValue( REFPROPERTYKEY Key, __out IPortableDeviceValues* pStore) { HRESULT hr = S_OK; PropVariantWrapper pvValue; if (IsEqualPropertyKey(Key, WPD_OBJECT_ID)) { // Add WPD_OBJECT_ID pvValue = ObjectID; hr = pStore->SetValue(WPD_OBJECT_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_NAME)) { // Add WPD_OBJECT_NAME pvValue = Name; hr = pStore->SetValue(WPD_OBJECT_NAME, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_NAME")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_PERSISTENT_UNIQUE_ID)) { // Add WPD_OBJECT_PERSISTENT_UNIQUE_ID pvValue = PersistentUniqueID; hr = pStore->SetValue(WPD_OBJECT_PERSISTENT_UNIQUE_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_PERSISTENT_UNIQUE_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_PARENT_ID)) { // Add WPD_OBJECT_PARENT_ID pvValue = ParentID; hr = pStore->SetValue(WPD_OBJECT_PARENT_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_PARENT_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_FORMAT)) { // Add WPD_OBJECT_FORMAT hr = pStore->SetGuidValue(WPD_OBJECT_FORMAT, Format); CHECK_HR(hr, ("Failed to set WPD_OBJECT_FORMAT")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTENT_TYPE)) { // Add WPD_OBJECT_CONTENT_TYPE hr = pStore->SetGuidValue(WPD_OBJECT_CONTENT_TYPE, ContentType); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CONTENT_TYPE")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CAN_DELETE)) { // Add WPD_OBJECT_CAN_DELETE hr = pStore->SetBoolValue(WPD_OBJECT_CAN_DELETE, CanDelete); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CAN_DELETE")); } else if (IsEqualPropertyKey(Key, WPD_FUNCTIONAL_OBJECT_CATEGORY)) { // Add WPD_FUNCTIONAL_OBJECT_CATEGORY hr = pStore->SetGuidValue(WPD_FUNCTIONAL_OBJECT_CATEGORY, FunctionalCategory); CHECK_HR(hr, ("Failed to set WPD_FUNCTIONAL_OBJECT_CATEGORY")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID)) { // Add WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID hr = pStore->SetStringValue(WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID, ContainerFunctionalObjectID); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID")); } else if (IsEqualPropertyKey(Key, WPD_SERVICE_VERSION)) { // Add WPD_SERVICE_VERSION hr = pStore->SetStringValue(WPD_SERVICE_VERSION, Version); CHECK_HR(hr, ("Failed to set WPD_SERVICE_VERSION")); } else if (IsEqualPropertyKey(Key, PKEY_Services_ServiceDisplayName)) { pvValue = HumanReadableName; hr = pStore->SetValue(PKEY_Services_ServiceDisplayName, &pvValue); CHECK_HR(hr, ("Failed to set PKEY_Services_ServiceDisplayName")); } else if (IsEqualPropertyKey(Key, PKEY_FullEnumSyncSvc_SyncFormat)) { hr = pStore->SetGuidValue(PKEY_FullEnumSyncSvc_SyncFormat, PreferredSyncFormat); CHECK_HR(hr, ("Failed to set PKEY_FullEnumSyncSvc_SyncFormat")); } else if (IsEqualPropertyKey(Key, PKEY_Services_ServiceIcon)) { hr = GetIconData(pStore); CHECK_HR(hr, "Failed to set PKEY_Services_ServiceIcon"); } else if (IsEqualPropertyKey(Key, PKEY_FullEnumSyncSvc_VersionProps)) { hr = GetVICData(pStore); CHECK_HR(hr, "Failed to set PKEY_FullEnumSyncSvc_VersionProps"); } else { hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); CHECK_HR(hr, "Property {%ws}.%d is not supported", CComBSTR(Key.fmtid), Key.pid); } return hr; }
bool GmExe::ReadSettings() { exeHandle->SkipDwords(1); GmkStream* settings = new GmkStream; exeHandle->Deserialize(settings,true); // Read icon GmkStream* iconData = GetIconData(); if (iconData) gmkHandle->settings.iconData = iconData; // Read settings gmkHandle->settings.fullscreen = settings->ReadBool(); gmkHandle->settings.interpolate = settings->ReadBool(); gmkHandle->settings.dontDrawBorder = settings->ReadBool(); gmkHandle->settings.displayCursor = settings->ReadBool(); gmkHandle->settings.scaling = settings->ReadDword(); gmkHandle->settings.allowWindowResize = settings->ReadBool(); gmkHandle->settings.onTop = settings->ReadBool(); gmkHandle->settings.colorOutsideRoom = settings->ReadDword(); gmkHandle->settings.setResolution = settings->ReadBool(); gmkHandle->settings.colorDepth = settings->ReadDword(); gmkHandle->settings.resolution = settings->ReadDword(); gmkHandle->settings.frequency = settings->ReadDword(); gmkHandle->settings.dontShowButtons = settings->ReadBool(); gmkHandle->settings.vsync = settings->ReadBool(); gmkHandle->settings.disableScreen = settings->ReadBool(); gmkHandle->settings.letF4 = settings->ReadBool(); gmkHandle->settings.letF1 = settings->ReadBool(); gmkHandle->settings.letEsc = settings->ReadBool(); gmkHandle->settings.letF5 = settings->ReadBool(); gmkHandle->settings.letF9 = settings->ReadBool(); gmkHandle->settings.treatCloseAsEsc = settings->ReadBool(); gmkHandle->settings.priority = settings->ReadDword(); gmkHandle->settings.freeze = settings->ReadBool(); gmkHandle->settings.loadingBar = settings->ReadDword(); if (gmkHandle->settings.loadingBar) { if (settings->ReadBool()) { gmkHandle->settings.backData = new GmkStream; settings->Deserialize(gmkHandle->settings.backData,true); } if (settings->ReadBool()) { gmkHandle->settings.frontData = new GmkStream; settings->Deserialize(gmkHandle->settings.frontData,true); } } gmkHandle->settings.customLoadImage = settings->ReadBool(); if (gmkHandle->settings.customLoadImage) { gmkHandle->settings.loadBar = new GmkStream; settings->Deserialize(gmkHandle->settings.loadBar,true); } gmkHandle->settings.transparent = settings->ReadBool(); gmkHandle->settings.translucency = settings->ReadDword(); gmkHandle->settings.scaleProgressBar = settings->ReadBool(); gmkHandle->settings.errorDisplay = settings->ReadBool(); gmkHandle->settings.errorLog = settings->ReadBool(); gmkHandle->settings.errorAbort = settings->ReadBool(); gmkHandle->settings.treatAsZero = settings->ReadDword(); if (version == 810) { gmkHandle->settings.errorOnUninitialization = (gmkHandle->settings.treatAsZero & 0x02) ? 1 : 0; gmkHandle->settings.treatAsZero &= 0x01; } delete settings; return true; }
/** \brief DragSelection callback. * Handles the results of a drag selection. */ void RemoteIconView::DragSelection( Point cStartPoint ) { /* Most of this is adapted from IconDirectoryView::DragSelection */ if( m_pcServer == NULL ) { DEBUG( "DragSelection with m_pcServer== NULL\n" ); return; } String zBase = m_pcServer->GetServerAddress(); Message cMsg( 1234 ); /* Message code isn't important */ /* Add all selected icons to the message, and find the icon under the mouse. */ int nCount = 0; int nLastSelected = -1; Point cIconPos = Point( 0,0 ); for( uint i = 0; i < GetIconCount(); i++ ) { if( GetIconSelected( i ) ) { RemoteIconData* pcData = (RemoteIconData*)GetIconData( i ); // DEBUG( " %s\n", pcData->m_cNode.m_zPath.c_str() ); cMsg.AddString( "remote-file/path", pcData->m_cNode.m_zPath ); cMsg.AddString( "server", zBase ); cMsg.AddBool( "is_dir", pcData->m_cNode.m_bIsDir ); if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( cStartPoint ) ) { cIconPos = GetIconPosition( i ); } nLastSelected = i; nCount++; } } if( nCount == 0 ) return; /* Create a drag&drop icon */ Bitmap cBitmap( (int)GetIconSize().x + 1, (int)GetIconSize().y + 1, CS_RGB32, Bitmap::ACCEPT_VIEWS | Bitmap::SHARE_FRAMEBUFFER ); View* pcView = new View( Rect( Point(0,0), GetIconSize() ), "temp" ); cBitmap.AddChild( pcView ); Image* pcIcon = NULL; String zLabel; if( nCount == 1 ) { /* Only one file selected; use its icon */ zLabel = GetIconString( nLastSelected, 0 ); pcIcon = GetIconImage( nLastSelected ); } else { /* Multiple files selected; use dir icon */ zLabel.Format( "%i items", nCount ); /* TODO: localise the string */ /* TODO: Fall back to resource if file isn't present */ File* pcFile = new File( "/system/icons/folder.png" ); BitmapImage* pcBitmapImage = new BitmapImage( pcFile ); Point cSize = (GetView() == VIEW_LIST || GetView() == VIEW_DETAILS ? Point( 24,24 ) : Point( 48,48 )); if( pcBitmapImage->GetSize() != cSize ) pcBitmapImage->SetSize( cSize ); pcIcon = pcBitmapImage; } if( pcIcon ) { RenderIcon( zLabel, pcIcon, pcView, Point(0,0) ); } cBitmap.Sync(); if( nCount != 1 ) delete( pcIcon ); BeginDrag( &cMsg, cStartPoint - cIconPos, &cBitmap ); }
/** \brief Message Handling Callback. * This handles all callbacks to the remote view window. */ void RemoteIconView::HandleMessage( Message* pcMessage ) { switch( pcMessage->GetCode() ) { case M_REMOTE_DIRLISTING: { if( !m_bUpdatePending ) { DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING while no dirlisting is pending!\n" ); return; } String zPath; if( pcMessage->FindString( "path", &zPath ) != 0 ) { DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING without path!\n" ); return; } if( zPath != m_zPath ) { DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING with wrong path %s! Expecting %s.\n", zPath.c_str(), m_zPath.c_str() ); return; } std::vector< RemoteNode >* pacNodes; /* The Server creates an array of RemoteNodes and passes us the pointer. We should delete it when done. */ if( pcMessage->FindPointer( "list", (void**)&pacNodes ) ) { DEBUG( "RemoteIconView: Got REMOTE_DIRLISTING without pointer to data!\n" ); return; } bool bInitial; if( pcMessage->FindBool( "initial", &bInitial ) != 0 ) bInitial = false; bool bFinal; if( pcMessage->FindBool( "final", &bFinal ) != 0 ) bFinal = false; SetContents( pacNodes, bInitial, bFinal ); if( pacNodes ) delete( pacNodes ); break; } /* Messages from the context menu */ case M_REMOTE_RENAME: { /* Check that only one icon is selected & get the selected icon */ uint nSelectedIcon = -1; uint nNumSelected = 0; for( uint i = 0; i < GetIconCount(); i++ ) { if( GetIconSelected( i ) ) { nSelectedIcon = i; nNumSelected++; } } if( nNumSelected != 1 ) { DEBUG( "RemoteView: Got M_REMOTE_RENAME while %i icons are selected!\n", nNumSelected ); break; } RemoteIconData* pcData = (RemoteIconData*)GetIconData( nSelectedIcon ); /* Display rename dialog */ Window* pcDialog = new RenameRequester( pcData->m_cNode.m_zPath, this ); pcDialog->CenterInWindow( GetWindow() ); pcDialog->Show(); pcDialog->MakeFocus( true ); break; } case M_REMOTE_DELETE: { /* Save a list of the selected files */ std::vector< RemoteNode >* pacDeleteList = new std::vector< RemoteNode >; for( uint i = 0; i < GetIconCount(); i++ ) { if( GetIconSelected( i ) ) { pacDeleteList->push_back( ((RemoteIconData*)GetIconData( i ))->m_cNode ); } } if( pacDeleteList->size() == 0 ) { DEBUG( "RemoteView: Got M_REMOTE_DELETE while no icons are selected!\n" ); delete( pacDeleteList ); break; } /* Display confirmation dialog */ Window* pcDialog = new DeleteConfirmDialog( pacDeleteList, this ); pcDialog->CenterInWindow( GetWindow() ); pcDialog->Show(); pcDialog->MakeFocus( true ); break; } case M_REMOTE_MKDIR: { Window* pcDialog = new MkDirRequester( m_zPath, this ); pcDialog->CenterInWindow( GetWindow() ); pcDialog->Show(); pcDialog->MakeFocus( true ); break; } case M_DELETE_CONFIRMED: { std::vector< RemoteNode >* pacDeleteList = NULL; pcMessage->FindPointer( "files", (void**)&pacDeleteList ); if( m_pcServer == NULL ) { /* Just in case */ DEBUG( "RemoteView: Got M_DELETE_CONFIRMED while m_pcServer == NULL!\n" ); delete( pacDeleteList ); break; } while( !pacDeleteList->empty() ) { RemoteNode* pcNode = &pacDeleteList->back(); if( pcNode->m_bIsDir ) { // DEBUG( "RemoteView: calling RemoveRemoteDir( %s )\n", pcNode->m_zPath.c_str() ); m_pcServer->RemoveRemoteDir( pcNode->m_zPath ); } else { // DEBUG( "RemoteView: calling DeleteRemote( '%s' )\n", pcNode->m_zPath.c_str() ); m_pcServer->DeleteRemoteFile( pcNode->m_zPath ); } pacDeleteList->pop_back(); } delete( pacDeleteList ); Update(); break; } case M_MKDIR_CONFIRMED: { String zPath; pcMessage->FindString( "remotepath", &zPath ); if( m_pcServer == NULL ) { DEBUG( "RemoteView: Got M_MKDIR_CONFIRMED while m_pcServer == NULL!\n" ); break; } m_pcServer->CreateRemoteDir( zPath ); Update(); break; } case M_RENAME_CONFIRMED: { String zOldPath, zNewPath; pcMessage->FindString( "old_path", &zOldPath ); pcMessage->FindString( "new_path", &zNewPath ); if( m_pcServer == NULL ) { DEBUG( "RemoteView: Got M_RENAME_CONFIRMED while m_pcServer == NULL!\n" ); break; } m_pcServer->MoveRemote( zOldPath, zNewPath ); Update(); break; } default: { IconView::HandleMessage( pcMessage ); } } }