diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:04:59 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:04:59 +0200 |
commit | f570e2f2685aa43aa518c2f8578391c1847cddbe (patch) | |
tree | b9376b3a7e807c5e0c4cf3d5615c14034d9675d6 /library | |
parent | 3.2 (diff) | |
download | FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.tar.gz FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.tar.bz2 FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.zip |
3.3
Diffstat (limited to 'library')
-rw-r--r-- | library/CustomGrid.cpp | 236 | ||||
-rw-r--r-- | library/FreeFileSync.xpm | 425 | ||||
-rw-r--r-- | library/Recycler/Recycler_Vista.vcproj | 409 | ||||
-rw-r--r-- | library/Recycler/dllmain.cpp | 22 | ||||
-rw-r--r-- | library/Recycler/recycler.cpp | 142 | ||||
-rw-r--r-- | library/Recycler/recycler.h | 24 | ||||
-rw-r--r-- | library/ShadowCopy/Shadow_2003.vcproj | 4 | ||||
-rw-r--r-- | library/ShadowCopy/Shadow_XP.vcproj | 4 | ||||
-rw-r--r-- | library/ShadowCopy/shadow.cpp | 1 | ||||
-rw-r--r-- | library/detectRenaming.cpp | 279 | ||||
-rw-r--r-- | library/detectRenaming.h | 20 | ||||
-rw-r--r-- | library/filter.cpp | 22 | ||||
-rw-r--r-- | library/filter.h | 54 | ||||
-rw-r--r-- | library/iconBuffer.cpp | 145 | ||||
-rw-r--r-- | library/iconBuffer.h | 8 | ||||
-rw-r--r-- | library/processXml.cpp | 6 | ||||
-rw-r--r-- | library/processXml.h | 11 | ||||
-rw-r--r-- | library/resources.cpp | 177 | ||||
-rw-r--r-- | library/resources.h | 159 | ||||
-rw-r--r-- | library/statistics.cpp | 8 | ||||
-rw-r--r-- | library/statistics.h | 2 |
21 files changed, 1234 insertions, 924 deletions
diff --git a/library/CustomGrid.cpp b/library/CustomGrid.cpp index 6c72859c..cba76f57 100644 --- a/library/CustomGrid.cpp +++ b/library/CustomGrid.cpp @@ -242,7 +242,7 @@ public: } //get filename in order to retrieve the icon from it - virtual Zstring getIconFile(const unsigned int row) const = 0; + virtual Zstring getIconFile(const unsigned int row) const = 0; //return "folder" if row points to a folder protected: template <SelectedSide side> @@ -311,7 +311,7 @@ private: if (!fsObj->isActive()) return COLOR_BLUE; //mark directories - else if (dynamic_cast<const DirMapping*>(fsObj) != NULL) + else if (isDirectoryMapping(*fsObj)) return COLOR_GREY; else return *wxWHITE; @@ -332,13 +332,18 @@ public: return CustomGridTableRim::GetValueSub<LEFT_SIDE>(row, col); } - virtual Zstring getIconFile(const unsigned int row) const + virtual Zstring getIconFile(const unsigned int row) const //return "folder" if row points to a folder { const FileSystemObject* fsObj = getRawData(row); if (fsObj && !fsObj->isEmpty<LEFT_SIDE>()) - return fsObj->getFullName<LEFT_SIDE>(); - else - return Zstring(); + { + if (isDirectoryMapping(*fsObj)) //it's a directory icon + return DefaultStr("folder"); + else + return fsObj->getFullName<LEFT_SIDE>(); + } + + return Zstring(); } }; @@ -351,20 +356,25 @@ public: return CustomGridTableRim::GetValueSub<RIGHT_SIDE>(row, col); } - virtual Zstring getIconFile(const unsigned int row) const + virtual Zstring getIconFile(const unsigned int row) const //return "folder" if row points to a folder { const FileSystemObject* fsObj = getRawData(row); if (fsObj && !fsObj->isEmpty<RIGHT_SIDE>()) { - //Optimization: if filename exists on both sides, always use left side's file: - //Icon should be the same on both sides anyway... - if (!fsObj->isEmpty<LEFT_SIDE>()) - return fsObj->getFullName<LEFT_SIDE>(); + if (isDirectoryMapping(*fsObj)) //it's a directory icon + return DefaultStr("folder"); else - return fsObj->getFullName<RIGHT_SIDE>(); + { + //Optimization: if filename exists on both sides, always use left side's file: + //Icon should be the same on both sides anyway... + if (!fsObj->isEmpty<LEFT_SIDE>()) + return fsObj->getFullName<LEFT_SIDE>(); + else + return fsObj->getFullName<RIGHT_SIDE>(); + } } - else - return Zstring(); + + return Zstring(); } }; @@ -435,6 +445,7 @@ private: case SO_UNRESOLVED_CONFLICT: return COLOR_YELLOW; case SO_DO_NOTHING: + case SO_EQUAL: return *wxWHITE; } } @@ -873,9 +884,9 @@ void CustomGrid::DrawColLabel(wxDC& dc, int col) if (col == m_marker.first) { if (m_marker.second == ASCENDING) - dc.DrawBitmap(*GlobalResources::getInstance().bitmapSmallUp, GetColRight(col) - 16 - 2, 2, true); //respect 2-pixel border + dc.DrawBitmap(GlobalResources::getInstance().getImageByName(wxT("smallUp")), GetColRight(col) - 16 - 2, 2, true); //respect 2-pixel border else - dc.DrawBitmap(*GlobalResources::getInstance().bitmapSmallDown, GetColRight(col) - 16 - 2, 2, true); //respect 2-pixel border + dc.DrawBitmap(GlobalResources::getInstance().getImageByName(wxT("smallDown")), GetColRight(col) - 16 - 2, 2, true); //respect 2-pixel border } } @@ -980,39 +991,48 @@ public: const Zstring fileName = m_gridDataTable->getIconFile(row); if (!fileName.empty()) { - wxIcon icon; - bool iconDrawnFully = false; - const bool iconLoaded = IconBuffer::getInstance().requestIcon(fileName, &icon); //returns false if icon is not in buffer - if (iconLoaded) + //first check if it is a directory icon: + if (fileName == DefaultStr("folder")) { - dc.DrawIcon(icon, rectShrinked.GetX() + LEFT_BORDER, rectShrinked.GetY()); + dc.DrawIcon(IconBuffer::getDirectoryIcon(), rectShrinked.GetX() + LEFT_BORDER, rectShrinked.GetY()); + m_loadIconSuccess[row] = true; //save status of last icon load -> used for async. icon loading + } + else //retrieve file icon + { + wxIcon icon; + bool iconDrawnFully = false; + const bool iconLoaded = IconBuffer::getInstance().requestFileIcon(fileName, &icon); //returns false if icon is not in buffer + if (iconLoaded) + { + dc.DrawIcon(icon, rectShrinked.GetX() + LEFT_BORDER, rectShrinked.GetY()); - //----------------------------------------------------------------------------------------------- - //only mark as successful if icon was drawn fully! - //(attention: when scrolling, rows get partially updated, which can result in the upper half being blank!) + //----------------------------------------------------------------------------------------------- + //only mark as successful if icon was drawn fully! + //(attention: when scrolling, rows get partially updated, which can result in the upper half being blank!) - //rect where icon was placed - wxRect iconRect(rect); //unscrolled - iconRect.x += LEFT_BORDER; - iconRect.SetWidth(IconBuffer::ICON_SIZE); + //rect where icon was placed + wxRect iconRect(rect); //unscrolled + iconRect.x += LEFT_BORDER; + iconRect.SetWidth(IconBuffer::ICON_SIZE); - //convert to scrolled coordinates - grid.CalcScrolledPosition(iconRect.x, iconRect.y, &iconRect.x, &iconRect.y); + //convert to scrolled coordinates + grid.CalcScrolledPosition(iconRect.x, iconRect.y, &iconRect.x, &iconRect.y); - wxRegionIterator regionsInv(grid.GetGridWindow()->GetUpdateRegion()); - while (regionsInv) - { - if (regionsInv.GetRect().Contains(iconRect)) + wxRegionIterator regionsInv(grid.GetGridWindow()->GetUpdateRegion()); + while (regionsInv) { - iconDrawnFully = true; - break; + if (regionsInv.GetRect().Contains(iconRect)) + { + iconDrawnFully = true; + break; + } + ++regionsInv; } - ++regionsInv; } + //----------------------------------------------------------------------------------------------- + //save status of last icon load -> used for async. icon loading + m_loadIconSuccess[row] = iconLoaded && iconDrawnFully; } - //----------------------------------------------------------------------------------------------- - //save status of last icon load -> used for async. icon loading - m_loadIconSuccess[row] = iconLoaded && iconDrawnFully; } } return; @@ -1364,7 +1384,7 @@ void CustomGridRim::getIconsToBeLoaded(std::vector<Zstring>& newLoad) //loads al if (!fileName.empty()) { //test if they are already loaded in buffer: - if (FreeFileSync::IconBuffer::getInstance().requestIcon(fileName)) + if (FreeFileSync::IconBuffer::getInstance().requestFileIcon(fileName)) { //exists in buffer: refresh Row for (int k = 0; k < totalCols; ++k) @@ -1644,28 +1664,31 @@ void CustomGridMiddle::showToolTip(int rowNumber, wxPoint pos) switch (syncOp) { case SO_CREATE_NEW_LEFT: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncCreateLeftAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncCreateLeftAct"))); break; case SO_CREATE_NEW_RIGHT: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncCreateRightAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncCreateRightAct"))); break; case SO_DELETE_LEFT: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncDeleteLeftAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncDeleteLeftAct"))); break; case SO_DELETE_RIGHT: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncDeleteRightAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncDeleteRightAct"))); break; case SO_OVERWRITE_LEFT: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncDirLeftAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncDirLeftAct"))); break; case SO_OVERWRITE_RIGHT: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncDirRightAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncDirRightAct"))); break; case SO_DO_NOTHING: - toolTip->show(getDescription(syncOp), pos, GlobalResources::getInstance().bitmapSyncDirNoneAct); + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("syncDirNoneAct"))); + break; + case SO_EQUAL: + toolTip->show(getDescription(syncOp), pos, &GlobalResources::getInstance().getImageByName(wxT("equalAct"))); break; case SO_UNRESOLVED_CONFLICT: - toolTip->show(fsObj->getSyncOpConflict(), pos, GlobalResources::getInstance().bitmapConflictAct); + toolTip->show(fsObj->getSyncOpConflict(), pos, &GlobalResources::getInstance().getImageByName(wxT("conflictAct"))); break; }; } @@ -1675,25 +1698,25 @@ void CustomGridMiddle::showToolTip(int rowNumber, wxPoint pos) switch (cmpRes) { case FILE_LEFT_SIDE_ONLY: - toolTip->show(getDescription(cmpRes), pos, GlobalResources::getInstance().bitmapLeftOnlyAct); + toolTip->show(getDescription(cmpRes), pos, &GlobalResources::getInstance().getImageByName(wxT("leftOnlyAct"))); break; case FILE_RIGHT_SIDE_ONLY: - toolTip->show(getDescription(cmpRes), pos, GlobalResources::getInstance().bitmapRightOnlyAct); + toolTip->show(getDescription(cmpRes), pos, &GlobalResources::getInstance().getImageByName(wxT("rightOnlyAct"))); break; case FILE_LEFT_NEWER: - toolTip->show(getDescription(cmpRes), pos, GlobalResources::getInstance().bitmapLeftNewerAct); + toolTip->show(getDescription(cmpRes), pos, &GlobalResources::getInstance().getImageByName(wxT("leftNewerAct"))); break; case FILE_RIGHT_NEWER: - toolTip->show(getDescription(cmpRes), pos, GlobalResources::getInstance().bitmapRightNewerAct); + toolTip->show(getDescription(cmpRes), pos, &GlobalResources::getInstance().getImageByName(wxT("rightNewerAct"))); break; case FILE_DIFFERENT: - toolTip->show(getDescription(cmpRes), pos, GlobalResources::getInstance().bitmapDifferentAct); + toolTip->show(getDescription(cmpRes), pos, &GlobalResources::getInstance().getImageByName(wxT("differentAct"))); break; case FILE_EQUAL: - toolTip->show(getDescription(cmpRes), pos, GlobalResources::getInstance().bitmapEqualAct); + toolTip->show(getDescription(cmpRes), pos, &GlobalResources::getInstance().getImageByName(wxT("equalAct"))); break; case FILE_CONFLICT: - toolTip->show(fsObj->getCatConflict(), pos, GlobalResources::getInstance().bitmapConflictAct); + toolTip->show(fsObj->getCatConflict(), pos, &GlobalResources::getInstance().getImageByName(wxT("conflictAct"))); break; } } @@ -1767,26 +1790,32 @@ int CustomGridMiddle::mousePosToRow(const wxPoint pos, BlockPosition* block) if (block) { *block = BLOCKPOS_CHECK_BOX; //default - if (gridDataTable->syncPreviewIsActive() && - row >= 0) - { - // cell: - // ---------------------------------- - // | checkbox | left | middle | right| - // ---------------------------------- - const wxRect rect = CellToRect(row, 0); - if (rect.GetWidth() > CHECK_BOX_WIDTH) + if (row >= 0) + { + const FileSystemObject* const fsObj = gridDataTable->getRawData(row); + if ( fsObj != NULL && //if valid row... + gridDataTable->syncPreviewIsActive() && + fsObj->getSyncOperation() != SO_EQUAL) //in sync-preview equal files shall be treated as in cmp result, i.e. as full checkbox { - const double blockWidth = (rect.GetWidth() - CHECK_BOX_WIDTH) / 3.0; - if (rect.GetX() + CHECK_BOX_WIDTH <= x && x < rect.GetX() + rect.GetWidth()) + // cell: + // ---------------------------------- + // | checkbox | left | middle | right| + // ---------------------------------- + + const wxRect rect = CellToRect(row, 0); + if (rect.GetWidth() > CHECK_BOX_WIDTH) { - if (x - (rect.GetX() + CHECK_BOX_WIDTH) < blockWidth) - *block = BLOCKPOS_LEFT; - else if (x - (rect.GetX() + CHECK_BOX_WIDTH) < 2 * blockWidth) - *block = BLOCKPOS_MIDDLE; - else - *block = BLOCKPOS_RIGHT; + const double blockWidth = (rect.GetWidth() - CHECK_BOX_WIDTH) / 3.0; + if (rect.GetX() + CHECK_BOX_WIDTH <= x && x < rect.GetX() + rect.GetWidth()) + { + if (x - (rect.GetX() + CHECK_BOX_WIDTH) < blockWidth) + *block = BLOCKPOS_LEFT; + else if (x - (rect.GetX() + CHECK_BOX_WIDTH) < 2 * blockWidth) + *block = BLOCKPOS_MIDDLE; + else + *block = BLOCKPOS_RIGHT; + } } } } @@ -1831,22 +1860,23 @@ void GridCellRendererMiddle::Draw(wxGrid& grid, rectShrinked.SetWidth(CHECK_BOX_WIDTH); wxGridCellRenderer::Draw(grid, attr, dc, rectShrinked, row, col, isSelected); - //print image into first block + //print checkbox into first block rectShrinked.SetX(rect.GetX() + 1); - //HIGHLIGHTNING: - if (rowIsHighlighted && m_gridMiddle->highlightedPos == CustomGridMiddle::BLOCKPOS_CHECK_BOX) + //HIGHLIGHTNING (checkbox): + if ( rowIsHighlighted && + m_gridMiddle->highlightedPos == CustomGridMiddle::BLOCKPOS_CHECK_BOX) { if (fsObj->isActive()) - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapCheckBoxTrueFocus, rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("checkboxTrueFocus")), rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); else - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapCheckBoxFalseFocus, rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("checkboxFalseFocus")), rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); } //default else if (fsObj->isActive()) - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapCheckBoxTrue, rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("checkboxTrue")), rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); else - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapCheckBoxFalse, rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("checkboxFalse")), rectShrinked, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); //clean remaining block of rect that will receive image of checkbox/directions rectShrinked.SetWidth(rect.GetWidth() - CHECK_BOX_WIDTH); @@ -1858,8 +1888,9 @@ void GridCellRendererMiddle::Draw(wxGrid& grid, { //print sync direction into second block - //HIGHLIGHTNING: - if (rowIsHighlighted && m_gridMiddle->highlightedPos != CustomGridMiddle::BLOCKPOS_CHECK_BOX) + //HIGHLIGHTNING (sync direction): + if ( rowIsHighlighted && + m_gridMiddle->highlightedPos != CustomGridMiddle::BLOCKPOS_CHECK_BOX) //don't allow changing direction for "=="-files switch (m_gridMiddle->highlightedPos) { case CustomGridMiddle::BLOCKPOS_CHECK_BOX: @@ -1885,25 +1916,25 @@ void GridCellRendererMiddle::Draw(wxGrid& grid, switch (fsObj->getCategory()) { case FILE_LEFT_SIDE_ONLY: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapLeftOnlySmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("leftOnlySmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; case FILE_RIGHT_SIDE_ONLY: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapRightOnlySmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("rightOnlySmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; case FILE_LEFT_NEWER: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapLeftNewerSmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("leftNewerSmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; case FILE_RIGHT_NEWER: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapRightNewerSmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("rightNewerSmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; case FILE_DIFFERENT: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapDifferentSmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("differentSmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; case FILE_EQUAL: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapEqualSmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("equalSmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; case FILE_CONFLICT: - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapConflictSmall, rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("conflictSmall")), rectShrinked, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); break; } } @@ -1935,9 +1966,9 @@ void CustomGridMiddle::DrawColLabel(wxDC& dc, int col) const wxRect rect(GetColLeft(col), 0, GetColWidth(col), GetColLabelSize()); if (gridDataTable->syncPreviewIsActive()) - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapSyncViewSmall, rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("syncViewSmall")), rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); else - dc.DrawLabel(wxEmptyString, *GlobalResources::getInstance().bitmapCmpViewSmall, rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); + dc.DrawLabel(wxEmptyString, GlobalResources::getInstance().getImageByName(wxT("cmpViewSmall")), rect, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); } @@ -1946,21 +1977,23 @@ const wxBitmap& FreeFileSync::getSyncOpImage(SyncOperation syncOp) switch (syncOp) //evaluate comparison result and sync direction { case SO_CREATE_NEW_LEFT: - return *GlobalResources::getInstance().bitmapCreateLeftSmall; + return GlobalResources::getInstance().getImageByName(wxT("createLeftSmall")); case SO_CREATE_NEW_RIGHT: - return *GlobalResources::getInstance().bitmapCreateRightSmall; + return GlobalResources::getInstance().getImageByName(wxT("createRightSmall")); case SO_DELETE_LEFT: - return *GlobalResources::getInstance().bitmapDeleteLeftSmall; + return GlobalResources::getInstance().getImageByName(wxT("deleteLeftSmall")); case SO_DELETE_RIGHT: - return *GlobalResources::getInstance().bitmapDeleteRightSmall; + return GlobalResources::getInstance().getImageByName(wxT("deleteRightSmall")); case SO_OVERWRITE_RIGHT: - return *GlobalResources::getInstance().bitmapSyncDirRightSmall; + return GlobalResources::getInstance().getImageByName(wxT("syncDirRightSmall")); case SO_OVERWRITE_LEFT: - return *GlobalResources::getInstance().bitmapSyncDirLeftSmall; + return GlobalResources::getInstance().getImageByName(wxT("syncDirLeftSmall")); case SO_DO_NOTHING: - return *GlobalResources::getInstance().bitmapSyncDirNoneSmall; + return GlobalResources::getInstance().getImageByName(wxT("syncDirNoneSmall")); + case SO_EQUAL: + return GlobalResources::getInstance().getImageByName(wxT("equalSmall")); case SO_UNRESOLVED_CONFLICT: - return *GlobalResources::getInstance().bitmapConflictSmall; + return GlobalResources::getInstance().getImageByName(wxT("conflictSmall")); } return wxNullBitmap; //dummy @@ -1970,3 +2003,8 @@ const wxBitmap& FreeFileSync::getSyncOpImage(SyncOperation syncOp) + + + + + diff --git a/library/FreeFileSync.xpm b/library/FreeFileSync.xpm deleted file mode 100644 index 339ccccb..00000000 --- a/library/FreeFileSync.xpm +++ /dev/null @@ -1,425 +0,0 @@ -/* XPM */ -static const char * FreeFileSync_xpm[] = { -"32 32 390 2", -" c None", -". c #005927", -"+ c #046A38", -"@ c #1B7E4B", -"# c #318F5A", -"$ c #308F56", -"% c #258C4D", -"& c #128040", -"* c #036C36", -"= c #005A31", -"- c #005D28", -"; c #1F7D4E", -"> c #76B08F", -", c #ADD9B7", -"' c #B9EABB", -") c #A5E9A5", -"! c #8BE38A", -"~ c #6DDB6D", -"{ c #4DD04E", -"] c #2FC136", -"^ c #19A82F", -"/ c #078433", -"( c #005D33", -"_ c #036B35", -": c #6FAA8C", -"< c #D9EEDE", -"[ c #E0FDDD", -"} c #BDF3BB", -"| c #9BE89A", -"1 c #7DE07C", -"2 c #5FD85F", -"3 c #44D143", -"4 c #32D131", -"5 c #2AD929", -"6 c #25E422", -"7 c #1CE31C", -"8 c #0CB522", -"9 c #017235", -"0 c #0B6F3B", -"a c #9EC8B0", -"b c #EEFFEC", -"c c #CAF5C9", -"d c #A7EAA7", -"e c #8AE38A", -"f c #6EDB6E", -"g c #51D351", -"h c #39CF38", -"i c #2CD32B", -"j c #26DB26", -"k c #20E11F", -"l c #19E719", -"m c #13EF12", -"n c #0CFE08", -"o c #03DB0F", -"p c #007F31", -"q c #056B36", -"r c #98C7AA", -"s c #E3FEE0", -"t c #B8EEB7", -"u c #99E699", -"v c #7DDF7D", -"w c #60D760", -"x c #45D144", -"y c #33D530", -"z c #2ADA28", -"A c #23DC23", -"B c #1CE41C", -"C c #16F113", -"D c #0FF90C", -"E c #08FA07", -"F c #02FE02", -"G c #00FF00", -"H c #00E20A", -"I c #007434", -"J c #005E2F", -"K c #005E30", -"L c #005B2E", -"M c #005D2E", -"N c #6BAB87", -"O c #D5FAD2", -"P c #AAEAAA", -"Q c #8CE28C", -"R c #70DB70", -"S c #53D453", -"T c #3BD13A", -"U c #2DD42C", -"V c #1CB72C", -"W c #0D9830", -"X c #078931", -"Y c #068D2F", -"Z c #06A527", -"` c #04CF14", -" . c #00FC02", -".. c #00C914", -"+. c #1A8347", -"@. c #5ABA6B", -"#. c #4FBA60", -"$. c #36AA4A", -"%. c #299E42", -"&. c #8FDF92", -"*. c #81DE81", -"=. c #65D665", -"-. c #47D047", -";. c #33D232", -">. c #27CE2A", -",. c #0D8F30", -"'. c #005A2F", -"). c #005F33", -"!. c #008A2C", -"~. c #00D210", -"{. c #009629", -"]. c #369C56", -"^. c #81E87D", -"/. c #66DE63", -"(. c #50D94D", -"_. c #3BD538", -":. c #2CD52B", -"<. c #2DDD2D", -"[. c #34E034", -"}. c #2FDB2F", -"|. c #29D728", -"1. c #25D228", -"2. c #098033", -"3. c #00502E", -"4. c #006536", -"5. c #00A820", -"6. c #00F802", -"7. c #00D510", -"8. c #005D31", -"9. c #1D8945", -"0. c #60D860", -"a. c #4AD34A", -"b. c #36CF36", -"c. c #2BD42B", -"d. c #22DC22", -"e. c #19E419", -"f. c #0FED0F", -"g. c #08F608", -"h. c #05FE03", -"i. c #05E80B", -"j. c #009E21", -"k. c #006832", -"l. c #005734", -"m. c #009029", -"n. c #00EF05", -"o. c #00832D", -"p. c #057238", -"q. c #40C646", -"r. c #38D137", -"s. c #1BE41B", -"t. c #13ED13", -"u. c #0AF50A", -"v. c #02FD02", -"w. c #00DF0C", -"x. c #008730", -"y. c #004F30", -"z. c #00852C", -"A. c #00F105", -"B. c #00B41F", -"C. c #005E32", -"D. c #1DA434", -"E. c #2EDA2B", -"F. c #00A426", -"G. c #008C27", -"H. c #00B91B", -"I. c #098234", -"J. c #23DB23", -"K. c #1CE61B", -"L. c #00C019", -"M. c #006131", -"N. c #006233", -"O. c #006E2B", -"P. c #00622F", -"Q. c #006535", -"R. c #12BD23", -"S. c #14F511", -"T. c #00EE07", -"U. c #00A424", -"V. c #00612F", -"W. c #3A8D63", -"X. c #8ABBA3", -"Y. c #B3D1C2", -"Z. c #468F6D", -"`. c #005E2A", -" + c #038230", -".+ c #0AEF0C", -"++ c #03FF02", -"@+ c #00F703", -"#+ c #007931", -"$+ c #006230", -"%+ c #509A75", -"&+ c #BBD6C9", -"*+ c #FEFEFF", -"=+ c #FFFFFF", -"-+ c #E6F2EB", -";+ c #1F7C4D", -">+ c #005D35", -",+ c #009624", -"'+ c #00FC01", -")+ c #00ED07", -"!+ c #00BC1A", -"~+ c #00812F", -"{+ c #004E2E", -"]+ c #378C60", -"^+ c #B5D5C3", -"/+ c #FAFFFA", -"(+ c #FBFFF9", -"_+ c #ECFCEB", -":+ c #E1F8E1", -"<+ c #D8F6D8", -"[+ c #DBFCD8", -"}+ c #7BBE8F", -"|+ c #009022", -"1+ c #009823", -"2+ c #007030", -"3+ c #00492B", -"4+ c #046734", -"5+ c #65AE81", -"6+ c #D0F3D1", -"7+ c #D8FBD6", -"8+ c #C3F2C3", -"9+ c #B7EEB7", -"0+ c #AEECAE", -"a+ c #A5EAA5", -"b+ c #9CE79C", -"c+ c #94E694", -"d+ c #89E189", -"e+ c #198446", -"f+ c #31895D", -"g+ c #116C44", -"h+ c #00502A", -"i+ c #036230", -"j+ c #62B878", -"k+ c #AEF1AC", -"l+ c #9DE99C", -"m+ c #8FE38F", -"n+ c #86E186", -"o+ c #7CDE7C", -"p+ c #73DC73", -"q+ c #6AD96A", -"r+ c #61D761", -"s+ c #57D457", -"t+ c #53D951", -"u+ c #2CA941", -"v+ c #005F31", -"w+ c #549F7A", -"x+ c #B0D0C1", -"y+ c #0B6A38", -"z+ c #0D773D", -"A+ c #6EDB6F", -"B+ c #6BDF67", -"C+ c #5DD65D", -"D+ c #55D355", -"E+ c #4BD24B", -"F+ c #43D143", -"G+ c #3BD13B", -"H+ c #34D234", -"I+ c #2DD42D", -"J+ c #27D827", -"K+ c #22DF21", -"L+ c #1BDB1E", -"M+ c #027A34", -"N+ c #167646", -"O+ c #EDFBEE", -"P+ c #9FCDAF", -"Q+ c #0A6E39", -"R+ c #168C3B", -"S+ c #2BC034", -"T+ c #28D828", -"U+ c #21DD21", -"V+ c #1EE01E", -"W+ c #1AE41A", -"X+ c #15E915", -"Y+ c #10EE10", -"Z+ c #0CF30C", -"`+ c #08F808", -" @ c #05FB04", -".@ c #03FE02", -"+@ c #01A323", -"@@ c #00592A", -"#@ c #88C79A", -"$@ c #DBFFD5", -"%@ c #88CB97", -"&@ c #157942", -"*@ c #006732", -"=@ c #1FB431", -"-@ c #24EC22", -";@ c #0CF40C", -">@ c #00C515", -",@ c #005A33", -"'@ c #309358", -")@ c #A4ECA3", -"!@ c #A3EDA0", -"~@ c #7DD584", -"{@ c #288E4B", -"]@ c #006232", -"^@ c #0F8535", -"/@ c #36C739", -"(@ c #35D334", -"_@ c #29D729", -":@ c #0FF10F", -"<@ c #05FB05", -"[@ c #01FE01", -"}@ c #00FE00", -"|@ c #00CB13", -"1@ c #006135", -"2@ c #016432", -"3@ c #5ABF68", -"4@ c #7AE377", -"5@ c #71DF6F", -"6@ c #66DB65", -"7@ c #39B04A", -"8@ c #11823A", -"9@ c #026633", -"0@ c #00522D", -"a@ c #036E34", -"b@ c #129E2E", -"c@ c #25D826", -"d@ c #22E221", -"e@ c #1DE41D", -"f@ c #19E919", -"g@ c #15ED15", -"h@ c #11F210", -"i@ c #039626", -"j@ c #008F2A", -"k@ c #00A323", -"l@ c #00A522", -"m@ c #008530", -"n@ c #00532D", -"o@ c #0F7F3D", -"p@ c #4BCE4E", -"q@ c #49D547", -"r@ c #41D040", -"s@ c #3ED63B", -"t@ c #33D133", -"u@ c #23BF2E", -"v@ c #17AF2C", -"w@ c #12AE2B", -"x@ c #11B826", -"y@ c #17D71E", -"z@ c #18EF15", -"A@ c #12F211", -"B@ c #05FC05", -"C@ c #00B919", -"D@ c #005C35", -"E@ c #0F8C35", -"F@ c #2AD52A", -"G@ c #27DE25", -"H@ c #21DE22", -"I@ c #1EE41D", -"J@ c #1BEC19", -"K@ c #17F314", -"L@ c #12F90F", -"M@ c #0DFD0A", -"N@ c #08FD06", -"O@ c #03FD03", -"P@ c #00CB12", -"Q@ c #006C37", -"R@ c #00562F", -"S@ c #07912F", -"T@ c #12E316", -"U@ c #0DFC0A", -"V@ c #09FA09", -"W@ c #01FF01", -"X@ c #00BE18", -"Y@ c #006D37", -"Z@ c #008030", -"`@ c #00C814", -" # c #00FA02", -".# c #00DD0C", -"+# c #009827", -"@# c #006437", -"## c #00852E", -"$# c #00B11E", -"%# c #00D111", -"&# c #00E40A", -"*# c #00EF06", -"=# c #00E908", -"-# c #00D80E", -";# c #00BD18", -"># c #009528", -",# c #006D35", -"'# c #004F2E", -")# c #00492C", -"!# c #006032", -"~# c #006A32", -"{# c #006D31", -"]# c #006B31", -"^# c #006533", -"/# c #005631", -" ", -" ", -" . + @ # $ % & * = ", -" - ; > , ' ) ! ~ { ] ^ / ( ", -" _ : < [ } | 1 2 3 4 5 6 7 8 9 ", -" 0 a b c d e f g h i j k l m n o p ", -" q r s t u v w x y z A B C D E F G H I ", -" J K L M N O P Q R S T U V W X Y Z ` .G G G ..( ", -" +.@.#.$.%.&.| *.=.-.;.>.,.'. ).!.~.G G G {. ", -" ].^./.(._.:.<.[.}.|.1.2.3. 4.5.6.G 7.8. ", -" 9.0.a.b.c.d.e.f.g.h.i.j.k. l.m.n.G o. ", -" p.q.r.c.A s.t.u.v.G G G w.x. y.z.A.B. ", -" C.D.E.A s.t.u.v.G G G G G F. G.H. ", -" I.J.K.t.u.v.G G G G G L.M. N.O.P. ", -" Q.R.S.u.v.G G G G T.U.= V.W.X.Y.Z.`. ", -" +.+++G G G @+L.#+ $+%+&+*+=+=+-+;+ ", -" >+,+'+G )+!+~+{+ ]+^+/+(+_+:+<+[+}+V. ", -" N.|+1+2+3+ 4+5+6+7+8+9+0+a+b+c+d+e+ ", -" f+g+h+ i+j+k+l+m+n+o+p+q+r+s+t+u+v+ ", -" w+x+y+ z+A+B+C+D+E+F+G+H+I+J+K+L+M+ ", -" N+O+P+Q+ L R+S+T+U+V+W+X+Y+Z+`+ @.@+@ ", -" @@#@$@%@&@ *@=@-@;@v.G G G G G G >@,@ ", -" '@)@!@~@{@]@ ^@/@(@_@s.:@<@[@}@G G |@1@ ", -" 2@3@4@5@6@7@8@9@0@ a@b@c@d@e@f@g@h@u.i@j@k@l@m@n@ ", -" o@p@q@r@s@t@u@v@w@x@y@z@A@;@`+B@F G C@D@ ", -" E@F@G@H@I@J@K@L@M@N@O@[@G G G G P@Q@ ", -" R@S@T@U@V@B@v.W@G G G G G G G X@Y@ ", -" Z@`@ #G G G G G G G G .#+#@# ", -" ( ##$#%#&#*#=#-#;#>#,#'# ", -" )#!#~#{#]#^#/# ", -" ", -" "}; diff --git a/library/Recycler/Recycler_Vista.vcproj b/library/Recycler/Recycler_Vista.vcproj new file mode 100644 index 00000000..65ab6609 --- /dev/null +++ b/library/Recycler/Recycler_Vista.vcproj @@ -0,0 +1,409 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="Vista Recycler" + ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" + RootNamespace="ShadowDll" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Recycler_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Recycler_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Recycler_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;RECYCLER_DLL_EXPORTS" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Recycler_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Quelldateien" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dllmain.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Headerdateien" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\recycler.cpp" + > + </File> + <File + RelativePath=".\recycler.h" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/library/Recycler/dllmain.cpp b/library/Recycler/dllmain.cpp new file mode 100644 index 00000000..834b4f88 --- /dev/null +++ b/library/Recycler/dllmain.cpp @@ -0,0 +1,22 @@ +// dllmain.cpp : Definiert den Einstiegspunkt für die DLL-Anwendung. + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/library/Recycler/recycler.cpp b/library/Recycler/recycler.cpp new file mode 100644 index 00000000..b551d4d0 --- /dev/null +++ b/library/Recycler/recycler.cpp @@ -0,0 +1,142 @@ +#include "recycler.h" + +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +#include <Shellapi.h> // Included for shell constants such as FO_* values +#include <shobjidl.h> // Required for necessary shell dependencies + +#include <algorithm> +#include <string> +#include <cstdio> +#include <comdef.h> + + +void writeString(const wchar_t* input, wchar_t* output, size_t outputBufferLen) +{ + const size_t newSize = min(wcslen(input) + 1, outputBufferLen); //including null-termination + memcpy(output, input, newSize * sizeof(wchar_t)); + output[newSize-1] = 0; //if output buffer is too small... +} + + +std::wstring numberToHexString(const long number) +{ + wchar_t result[100]; + swprintf(result, 100, L"0x%08x", number); + return std::wstring(result); +} + + +void writeErrorMsg(const wchar_t* input, HRESULT hr, wchar_t* output, size_t outputBufferLen) +{ + std::wstring formattedMsg(input); + formattedMsg += L" ("; + formattedMsg += numberToHexString(hr); + formattedMsg += L": "; + formattedMsg += _com_error(hr).ErrorMessage(); + formattedMsg += L")"; + + writeString(formattedMsg.c_str(), output, outputBufferLen); +} + + +//IShellItem resource management +template <class T> +class ReleaseAtExit +{ +public: + ReleaseAtExit(T*& item) : item_(item) {} + ~ReleaseAtExit() + { + if (item_ != NULL) + item_->Release(); + } +private: + T*& item_; +}; + + +bool Utility::moveToRecycleBin(const wchar_t* fileNames[], + size_t fileNo, //size of fileNames array + wchar_t* errorMessage, + size_t errorBufferLen) +{ + HRESULT hr; + + // Create the IFileOperation interface + IFileOperation* pfo = NULL; + ReleaseAtExit<IFileOperation> dummy(pfo); + hr = CoCreateInstance(CLSID_FileOperation, + NULL, + CLSCTX_ALL, + IID_PPV_ARGS(&pfo)); + if (FAILED(hr)) + { + writeErrorMsg(L"Error calling \"CoCreateInstance\".", hr, errorMessage, errorBufferLen); + return false; + } + + // Set the operation flags. Turn off all UI + // from being shown to the user during the + // operation. This includes error, confirmation + // and progress dialogs. + hr = pfo->SetOperationFlags(FOF_ALLOWUNDO | + FOF_NOCONFIRMATION | + FOF_SILENT | + FOF_NOERRORUI); + if (FAILED(hr)) + { + writeErrorMsg(L"Error calling \"SetOperationFlags\".", hr, errorMessage, errorBufferLen); + return false; + } + + for (size_t i = 0; i < fileNo; ++i) + { + //create file/folder item object + IShellItem* psiFile = NULL; + ReleaseAtExit<IShellItem> dummy2(psiFile); + hr = SHCreateItemFromParsingName(fileNames[i], + NULL, + IID_PPV_ARGS(&psiFile)); + if (FAILED(hr)) + { + std::wstring message(L"Error calling \"SHCreateItemFromParsingName\" for file "); + message += std::wstring(L"\"") + fileNames[i] + L"\"."; + writeErrorMsg(message.c_str(), hr, errorMessage, errorBufferLen); + return false; + } + + hr = pfo->DeleteItem(psiFile, NULL); + if (FAILED(hr)) + { + writeErrorMsg(L"Error calling \"DeleteItem\".", hr, errorMessage, errorBufferLen); + return false; + } + } + + //perform actual operations + hr = pfo->PerformOperations(); + if (FAILED(hr)) + { + writeErrorMsg(L"Error calling \"PerformOperations\".", hr, errorMessage, errorBufferLen); + return false; + } + + //check if errors occured: if FOFX_EARLYFAILURE is not used, PerformOperations() can return with success despite errors! + BOOL pfAnyOperationsAborted = FALSE; + hr = pfo->GetAnyOperationsAborted(&pfAnyOperationsAborted); + if (FAILED(hr)) + { + writeErrorMsg(L"Error calling \"GetAnyOperationsAborted\".", hr, errorMessage, errorBufferLen); + return false; + } + + + if (pfAnyOperationsAborted == TRUE) + { + writeString(L"Operation did not complete successfully.", errorMessage, errorBufferLen); + return false; + } + + return true; +} diff --git a/library/Recycler/recycler.h b/library/Recycler/recycler.h new file mode 100644 index 00000000..59bec9dc --- /dev/null +++ b/library/Recycler/recycler.h @@ -0,0 +1,24 @@ +#ifndef RECYCLER_DLL_H +#define RECYCLER_DLL_H + +#ifdef RECYCLER_DLL_EXPORTS +#define RECYCLER_DLL_API extern "C" __declspec(dllexport) +#else +#define RECYCLER_DLL_API extern "C" __declspec(dllimport) +#endif + + +namespace Utility +{ +//COM needs to be initialized before calling any of these functions! CoInitializeEx/CoUninitialize + +RECYCLER_DLL_API +bool moveToRecycleBin(const wchar_t* fileNames[], + size_t fileNo, //size of fileNames array + wchar_t* errorMessage, + size_t errorBufferLen); +} + + + +#endif //RECYCLER_DLL_H diff --git a/library/ShadowCopy/Shadow_2003.vcproj b/library/ShadowCopy/Shadow_2003.vcproj index 560deb8d..49730440 100644 --- a/library/ShadowCopy/Shadow_2003.vcproj +++ b/library/ShadowCopy/Shadow_2003.vcproj @@ -205,7 +205,7 @@ Optimization="2" EnableIntrinsicFunctions="true" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" - RuntimeLibrary="2" + RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -287,7 +287,7 @@ Optimization="2" EnableIntrinsicFunctions="true" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" - RuntimeLibrary="2" + RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" diff --git a/library/ShadowCopy/Shadow_XP.vcproj b/library/ShadowCopy/Shadow_XP.vcproj index 6c1cbaaa..74b231de 100644 --- a/library/ShadowCopy/Shadow_XP.vcproj +++ b/library/ShadowCopy/Shadow_XP.vcproj @@ -205,7 +205,7 @@ Optimization="2" EnableIntrinsicFunctions="true" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" - RuntimeLibrary="2" + RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" @@ -287,7 +287,7 @@ Optimization="2" EnableIntrinsicFunctions="true" PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" - RuntimeLibrary="2" + RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" diff --git a/library/ShadowCopy/shadow.cpp b/library/ShadowCopy/shadow.cpp index cbc4b085..0693815f 100644 --- a/library/ShadowCopy/shadow.cpp +++ b/library/ShadowCopy/shadow.cpp @@ -28,6 +28,7 @@ void writeString(const wchar_t* input, wchar_t* output, unsigned int outputBuffe { const size_t newSize = min(wcslen(input) + 1, outputBufferLen); //including null-termination memcpy(output, input, newSize * sizeof(wchar_t)); + output[newSize-1] = 0; //if output buffer is too small... } diff --git a/library/detectRenaming.cpp b/library/detectRenaming.cpp new file mode 100644 index 00000000..d2b4a62c --- /dev/null +++ b/library/detectRenaming.cpp @@ -0,0 +1,279 @@ +#include "detectRenaming.h" +#include <map> +#include <vector> +#include <boost/bind.hpp> + +using namespace FreeFileSync; + +/*detect renamed files: +Example: + X -> |_| Create right +|_| -> Y Delete right + +is detected as: + +Rename Y to X on right + +Algorithm: +---------- +DB-file left ---filename, Metadata(=:MD)---> DB-file right + /|\ | + | fileID, MD + fileID, MD | + | \|/ + X Y + +*/ + + +class FindDBAssoc +{ + /* + load and associate db-files by filename and metadata(size, date) + fileID, MD |-> fileID + */ +public: + struct AssocKey + { + AssocKey(const Utility::FileID& fileId, + const wxLongLong& lastWriteTimeRaw, + const wxULongLong& fileSize); + + bool operator<(const AssocKey& other) const; + + Utility::FileID fileId_; + wxLongLong lastWriteTimeRaw_; + wxULongLong fileSize_; + }; + + FindDBAssoc(const FreeFileSync::BaseDirMapping& baseMapping, + std::map<AssocKey, Utility::FileID>& assocDBLeftToRight); + +private: + void recurse(const DirContainer& leftSide, const DirContainer& rightSide); + + std::map<AssocKey, Utility::FileID>& assocDBLeftToRight_; //--> +}; + + +inline +FindDBAssoc::AssocKey::AssocKey(const Utility::FileID& fileId, + const wxLongLong& lastWriteTimeRaw, + const wxULongLong& fileSize) : + fileId_(fileId), + lastWriteTimeRaw_(lastWriteTimeRaw), + fileSize_(fileSize) {} + + +inline +bool FindDBAssoc::AssocKey::operator<(const AssocKey& other) const +{ + if (fileId_ != other.fileId_) + return fileId_ < other.fileId_; + + if (lastWriteTimeRaw_ != other.lastWriteTimeRaw_) + return lastWriteTimeRaw_ < other.lastWriteTimeRaw_; + + return fileSize_ < other.fileSize_; +} + + +FindDBAssoc::FindDBAssoc(const FreeFileSync::BaseDirMapping& baseMapping, + std::map<AssocKey, Utility::FileID>& assocDBLeftToRight) : assocDBLeftToRight_(assocDBLeftToRight) +{ + try + { + std::pair<FreeFileSync::DirInfoPtr, FreeFileSync::DirInfoPtr> dbInfo = + FreeFileSync::loadFromDisk(baseMapping); //throw (FileError) + + recurse(dbInfo.first->baseDirContainer, + dbInfo.second->baseDirContainer); + } + catch (...) {} //swallow... +} + + +void FindDBAssoc::recurse(const DirContainer& leftSide, const DirContainer& rightSide) +{ + for (DirContainer::SubFileList::const_iterator i = leftSide.getSubFiles().begin(); i != leftSide.getSubFiles().end(); ++i) + { + const FileDescriptor& fileDescrI = i->second.getData(); + if (!fileDescrI.fileIdentifier.isNull()) //fileIdentifier may be NULL + { + const DirContainer::SubFileList::const_iterator j = rightSide.getSubFiles().find(i->first); + + //find files that exist on left and right + if (j != rightSide.getSubFiles().end()) + { + const FileDescriptor& fileDescrJ = j->second.getData(); + if (!fileDescrJ.fileIdentifier.isNull()) //fileIdentifier may be NULL + { + if ( fileDescrI.lastWriteTimeRaw == fileDescrJ.lastWriteTimeRaw && + fileDescrI.fileSize == fileDescrJ.fileSize) + { + assocDBLeftToRight_[AssocKey(fileDescrI.fileIdentifier, + fileDescrI.lastWriteTimeRaw, + fileDescrI.fileSize)] = fileDescrJ.fileIdentifier; + } + } + } + } + } + +//----------------------------------------------------------------------------------------------- + for (DirContainer::SubDirList::const_iterator i = leftSide.getSubDirs().begin(); i != leftSide.getSubDirs().end(); ++i) + { + const DirContainer::SubDirList::const_iterator j = rightSide.getSubDirs().find(i->first); + + //directories that exist on both sides + if (j != rightSide.getSubDirs().end()) + { + recurse(i->second, j->second); //recurse into subdirectories + } + } +} + + + +class FindRenameCandidates +{ +public: + FindRenameCandidates(FreeFileSync::BaseDirMapping& baseMapping) + { + FindDBAssoc(baseMapping, + assocDBLeftToRight); + + if (!assocDBLeftToRight.empty()) + recurse(baseMapping); + } + + void getRenameCandidates(std::vector<std::pair<FileMapping*, FileMapping*> >& renameOnLeft, + std::vector<std::pair<FileMapping*, FileMapping*> >& renameOnRight); + +private: + void recurse(HierarchyObject& hierObj) + { + //files + std::for_each(hierObj.subFiles.begin(), hierObj.subFiles.end(), + boost::bind(&FindRenameCandidates::processFile, this, _1)); + + //directories + std::for_each(hierObj.subDirs.begin(), hierObj.subDirs.end(), + boost::bind(&FindRenameCandidates::recurse, this, _1));//recursion + } + + void processFile(FileMapping& fileObj) + { + switch (fileObj.getSyncOperation()) //evaluate comparison result and sync direction + { + case SO_CREATE_NEW_LEFT: + if (!fileObj.getFileID<RIGHT_SIDE>().isNull()) //fileIdentifier may be NULL + createLeft[FindDBAssoc::AssocKey(fileObj.getFileID<RIGHT_SIDE>(), + fileObj.getLastWriteTime<RIGHT_SIDE>(), + fileObj.getFileSize<RIGHT_SIDE>())] = &fileObj; + break; + + case SO_CREATE_NEW_RIGHT: + if (!fileObj.getFileID<LEFT_SIDE>().isNull()) //fileIdentifier may be NULL + createRight.push_back(&fileObj); + break; + + case SO_DELETE_LEFT: + if (!fileObj.getFileID<LEFT_SIDE>().isNull()) //fileIdentifier may be NULL + deleteLeft.push_back(&fileObj); + break; + + case SO_DELETE_RIGHT: + if (!fileObj.getFileID<RIGHT_SIDE>().isNull()) //fileIdentifier may be NULL + deleteRight[FindDBAssoc::AssocKey(fileObj.getFileID<RIGHT_SIDE>(), + fileObj.getLastWriteTime<RIGHT_SIDE>(), + fileObj.getFileSize<RIGHT_SIDE>())] = &fileObj; + break; + + case SO_OVERWRITE_RIGHT: + case SO_OVERWRITE_LEFT: + case SO_DO_NOTHING: + case SO_UNRESOLVED_CONFLICT: + break; + } + + } + + + std::vector<FileMapping*> createRight; //pointer always bound! + std::vector<FileMapping*> deleteLeft; // +// | +// \|/ + std::map<FindDBAssoc::AssocKey, Utility::FileID> assocDBLeftToRight; +// | +// \|/ + std::map<FindDBAssoc::AssocKey, FileMapping*> deleteRight; //pointer always bound! + std::map<FindDBAssoc::AssocKey, FileMapping*> createLeft; // + +}; + + + +void FindRenameCandidates::getRenameCandidates( + std::vector<std::pair<FileMapping*, FileMapping*> >& renameOnLeft, + std::vector<std::pair<FileMapping*, FileMapping*> >& renameOnRight) +{ + for (std::vector<FileMapping*>::const_iterator crRightIter = createRight.begin(); + crRightIter != createRight.end(); + ++crRightIter) + { + const FindDBAssoc::AssocKey assocDbKey((*crRightIter)->getFileID<LEFT_SIDE>(), + (*crRightIter)->getLastWriteTime<LEFT_SIDE>(), + (*crRightIter)->getFileSize<LEFT_SIDE>()); + + const std::map<FindDBAssoc::AssocKey, Utility::FileID>::const_iterator assocDBIter = + assocDBLeftToRight.find(assocDbKey); + + if (assocDBIter != assocDBLeftToRight.end()) + { + std::map<FindDBAssoc::AssocKey, FileMapping*>::const_iterator delRightIter = + deleteRight.find(FindDBAssoc::AssocKey(assocDBIter->second, //FileID of right side + assocDbKey.lastWriteTimeRaw_, + assocDbKey.fileSize_)); + + if (delRightIter != deleteRight.end()) + { + renameOnRight.push_back(std::make_pair(*crRightIter, delRightIter->second)); + } + } + } + //------------------------------------------------------------------------------------------------ + for (std::vector<FileMapping*>::const_iterator delLeftIter = deleteLeft.begin(); + delLeftIter != deleteLeft.end(); + ++delLeftIter) + { + const FindDBAssoc::AssocKey assocDbKey((*delLeftIter)->getFileID<LEFT_SIDE>(), + (*delLeftIter)->getLastWriteTime<LEFT_SIDE>(), + (*delLeftIter)->getFileSize<LEFT_SIDE>()); + + const std::map<FindDBAssoc::AssocKey, Utility::FileID>::const_iterator assocDBIter = + assocDBLeftToRight.find(assocDbKey); + + if (assocDBIter != assocDBLeftToRight.end()) + { + std::map<FindDBAssoc::AssocKey, FileMapping*>::const_iterator createLeftIter = + createLeft.find(FindDBAssoc::AssocKey(assocDBIter->second, //FileID of right side + assocDbKey.lastWriteTimeRaw_, + assocDbKey.fileSize_)); + + if (createLeftIter != createLeft.end()) + { + renameOnLeft.push_back(std::make_pair(createLeftIter->second, *delLeftIter)); + } + } + } +} + + +void FreeFileSync::getRenameCandidates(FreeFileSync::BaseDirMapping& baseMapping, //in + std::vector<std::pair<CreateOnLeft, DeleteOnLeft> >& renameOnLeft, //out + std::vector<std::pair<CreateOnRight, DeleteOnRight> >& renameOnRight) //out throw()! +{ + FindRenameCandidates(baseMapping).getRenameCandidates(renameOnLeft, renameOnRight); +} + diff --git a/library/detectRenaming.h b/library/detectRenaming.h new file mode 100644 index 00000000..82cb543e --- /dev/null +++ b/library/detectRenaming.h @@ -0,0 +1,20 @@ +#ifndef DETECTRENAMING_H_INCLUDED +#define DETECTRENAMING_H_INCLUDED + +#include "../fileHierarchy.h" + + +//identify a file "create and delete"-operation as a file renaming! + +namespace FreeFileSync +{ +typedef FileMapping* CreateOnLeft; +typedef FileMapping* DeleteOnLeft; +typedef FileMapping* CreateOnRight; +typedef FileMapping* DeleteOnRight; +void getRenameCandidates(FreeFileSync::BaseDirMapping& baseMapping, //in + std::vector<std::pair<CreateOnLeft, DeleteOnLeft> >& renameOnLeft, //out + std::vector<std::pair<CreateOnRight, DeleteOnRight> >& renameOnRight); //out throw()! +} + +#endif // DETECTRENAMING_H_INCLUDED diff --git a/library/filter.cpp b/library/filter.cpp index 6565da2e..25877513 100644 --- a/library/filter.cpp +++ b/library/filter.cpp @@ -10,24 +10,24 @@ #include "../shared/loki/LokiTypeInfo.h" #include "../shared/serialize.h" -using FreeFileSync::FilterProcess; +using FreeFileSync::BaseFilter; using FreeFileSync::NameFilter; //-------------------------------------------------------------------------------------------------- -bool FilterProcess::operator==(const FilterProcess& other) const +bool BaseFilter::operator==(const BaseFilter& other) const { return !(*this < other) && !(other < *this); } -bool FilterProcess::operator!=(const FilterProcess& other) const +bool BaseFilter::operator!=(const BaseFilter& other) const { return !(*this == other); } -bool FilterProcess::operator<(const FilterProcess& other) const +bool BaseFilter::operator<(const BaseFilter& other) const { if (Loki::TypeInfo(typeid(*this)) != typeid(other)) return Loki::TypeInfo(typeid(*this)) < typeid(other); @@ -37,7 +37,7 @@ bool FilterProcess::operator<(const FilterProcess& other) const } -void FilterProcess::saveFilter(wxOutputStream& stream) const //serialize derived object +void BaseFilter::saveFilter(wxOutputStream& stream) const //serialize derived object { //save type information Utility::writeString(stream, uniqueClassIdentifier()); @@ -47,7 +47,7 @@ void FilterProcess::saveFilter(wxOutputStream& stream) const //serialize derived } -FilterProcess::FilterRef FilterProcess::loadFilter(wxInputStream& stream) +BaseFilter::FilterRef BaseFilter::loadFilter(wxInputStream& stream) { //read type information const Zstring uniqueClassId = Utility::readString(stream); @@ -72,7 +72,7 @@ void addFilterEntry(const Zstring& filtername, std::set<Zstring>& fileFilter, st #ifdef FFS_WIN //Windows does NOT distinguish between upper/lower-case - filterFormatted.MakeLower(); + filterFormatted.MakeUpper(); #elif defined FFS_LINUX //Linux DOES distinguish between upper/lower-case: nothing to do here #endif @@ -140,7 +140,7 @@ bool matchesFilter(const DefaultChar* name, const std::set<Zstring>& filter) { #ifdef FFS_WIN //Windows does NOT distinguish between upper/lower-case Zstring nameFormatted = name; - nameFormatted.MakeLower(); + nameFormatted.MakeUpper(); #elif defined FFS_LINUX //Linux DOES distinguish between upper/lower-case const DefaultChar* const nameFormatted = name; //nothing to do here #endif @@ -180,7 +180,7 @@ bool matchesFilterBegin(const DefaultChar* name, const std::set<Zstring>& filter { #ifdef FFS_WIN //Windows does NOT distinguish between upper/lower-case Zstring nameFormatted = name; - nameFormatted.MakeLower(); + nameFormatted.MakeUpper(); #elif defined FFS_LINUX //Linux DOES distinguish between upper/lower-case const DefaultChar* const nameFormatted = name; //nothing to do here #endif @@ -265,7 +265,7 @@ bool NameFilter::isNull() const } -bool NameFilter::cmpLessSameType(const FilterProcess& other) const +bool NameFilter::cmpLessSameType(const BaseFilter& other) const { //typeid(*this) == typeid(other) in this context! assert(typeid(*this) == typeid(other)); @@ -300,7 +300,7 @@ void NameFilter::save(wxOutputStream& stream) const } -FilterProcess::FilterRef NameFilter::load(wxInputStream& stream) //"constructor" +BaseFilter::FilterRef NameFilter::load(wxInputStream& stream) //"constructor" { const Zstring include = Utility::readString(stream); const Zstring exclude = Utility::readString(stream); diff --git a/library/filter.h b/library/filter.h index efdb01fd..ea725291 100644 --- a/library/filter.h +++ b/library/filter.h @@ -11,17 +11,23 @@ namespace FreeFileSync //------------------------------------------------------------------ /* class hierarchy: - FilterProcess (interface) + BaseFilter (interface) /|\ _________|_____________ | | | NullFilter NameFilter CombinedFilter */ -class FilterProcess //interface for filtering +/* +Semantics of BaseFilter: +1. using it creates a NEW folder hierarchy! -> must be respected by <Automatic>-mode! +2. it applies equally to both sides => it always matches either both sides or none! => can be used while traversing a single folder! +*/ + +class BaseFilter //interface for filtering { public: - virtual ~FilterProcess() {} + virtual ~BaseFilter() {} //filtering virtual bool passFileFilter(const DefaultChar* relFilename) const = 0; @@ -32,11 +38,11 @@ public: virtual bool isNull() const = 0; //filter is equivalent to NullFilter, but may be technically slower //comparison - bool operator<(const FilterProcess& other) const; - bool operator==(const FilterProcess& other) const; - bool operator!=(const FilterProcess& other) const; + bool operator<(const BaseFilter& other) const; + bool operator==(const BaseFilter& other) const; + bool operator!=(const BaseFilter& other) const; - typedef boost::shared_ptr<const FilterProcess> FilterRef; //always bound by design! + typedef boost::shared_ptr<const BaseFilter> FilterRef; //always bound by design! //serialization void saveFilter(wxOutputStream& stream) const; //serialize derived object @@ -45,11 +51,11 @@ public: private: virtual Zstring uniqueClassIdentifier() const = 0; //get identifier, used for serialization virtual void save(wxOutputStream& stream) const = 0; //serialization - virtual bool cmpLessSameType(const FilterProcess& other) const = 0; //typeid(*this) == typeid(other) in this context! + virtual bool cmpLessSameType(const BaseFilter& other) const = 0; //typeid(*this) == typeid(other) in this context! }; -class NullFilter : public FilterProcess //no filtering at all +class NullFilter : public BaseFilter //no filtering at all { public: static FilterRef load(wxInputStream& stream); //"serial constructor" @@ -60,11 +66,11 @@ public: private: virtual Zstring uniqueClassIdentifier() const; virtual void save(wxOutputStream& stream) const {} - virtual bool cmpLessSameType(const FilterProcess& other) const; + virtual bool cmpLessSameType(const BaseFilter& other) const; }; -class NameFilter : public FilterProcess //standard filter by filename +class NameFilter : public BaseFilter //standard filter by filename { public: NameFilter(const Zstring& includeFilter, const Zstring& excludeFilter); @@ -77,7 +83,7 @@ public: private: virtual Zstring uniqueClassIdentifier() const; virtual void save(wxOutputStream& stream) const; - virtual bool cmpLessSameType(const FilterProcess& other) const; + virtual bool cmpLessSameType(const BaseFilter& other) const; std::set<Zstring> filterFileIn; std::set<Zstring> filterFolderIn; @@ -89,7 +95,7 @@ private: }; -class CombinedFilter : public FilterProcess //combine two filters to match if and only if both match +class CombinedFilter : public BaseFilter //combine two filters to match if and only if both match { public: CombinedFilter(const FilterRef& first, const FilterRef& second) : first_(first), second_(second) {} @@ -102,7 +108,7 @@ public: private: virtual Zstring uniqueClassIdentifier() const; virtual void save(wxOutputStream& stream) const; - virtual bool cmpLessSameType(const FilterProcess& other) const; + virtual bool cmpLessSameType(const BaseFilter& other) const; const FilterRef first_; const FilterRef second_; @@ -110,8 +116,8 @@ private: //small helper method: remove Null-filters -FilterProcess::FilterRef combineFilters(const FilterProcess::FilterRef& first, - const FilterProcess::FilterRef& second); +BaseFilter::FilterRef combineFilters(const BaseFilter::FilterRef& first, + const BaseFilter::FilterRef& second); @@ -132,7 +138,7 @@ FilterProcess::FilterRef combineFilters(const FilterProcess::FilterRef& first, //---------------Inline Implementation--------------------------------------------------- inline -FilterProcess::FilterRef NullFilter::load(wxInputStream& stream) //"serial constructor" +BaseFilter::FilterRef NullFilter::load(wxInputStream& stream) //"serial constructor" { return FilterRef(new NullFilter); } @@ -161,7 +167,7 @@ bool NullFilter::isNull() const inline -bool NullFilter::cmpLessSameType(const FilterProcess& other) const +bool NullFilter::cmpLessSameType(const BaseFilter& other) const { //typeid(*this) == typeid(other) in this context! assert(typeid(*this) == typeid(other)); @@ -200,7 +206,7 @@ bool CombinedFilter::isNull() const inline -bool CombinedFilter::cmpLessSameType(const FilterProcess& other) const +bool CombinedFilter::cmpLessSameType(const BaseFilter& other) const { //typeid(*this) == typeid(other) in this context! assert(typeid(*this) == typeid(other)); @@ -229,7 +235,7 @@ void CombinedFilter::save(wxOutputStream& stream) const inline -FilterProcess::FilterRef CombinedFilter::load(wxInputStream& stream) //"constructor" +BaseFilter::FilterRef CombinedFilter::load(wxInputStream& stream) //"constructor" { FilterRef first = loadFilter(stream); FilterRef second = loadFilter(stream); @@ -239,13 +245,13 @@ FilterProcess::FilterRef CombinedFilter::load(wxInputStream& stream) //"construc inline -FilterProcess::FilterRef combineFilters(const FilterProcess::FilterRef& first, - const FilterProcess::FilterRef& second) +BaseFilter::FilterRef combineFilters(const BaseFilter::FilterRef& first, + const BaseFilter::FilterRef& second) { if (first->isNull()) { if (second->isNull()) - return FilterProcess::FilterRef(new NullFilter); + return BaseFilter::FilterRef(new NullFilter); else return second; } @@ -254,7 +260,7 @@ FilterProcess::FilterRef combineFilters(const FilterProcess::FilterRef& first, if (second->isNull()) return first; else - return FilterProcess::FilterRef(new CombinedFilter(first, second)); + return BaseFilter::FilterRef(new CombinedFilter(first, second)); } } diff --git a/library/iconBuffer.cpp b/library/iconBuffer.cpp index d386c85a..21f85372 100644 --- a/library/iconBuffer.cpp +++ b/library/iconBuffer.cpp @@ -7,10 +7,82 @@ #include <map> #include <queue> #include <stdexcept> +#include <set> using FreeFileSync::IconBuffer; +const wxIcon& IconBuffer::getDirectoryIcon() //one folder icon should be sufficient... +{ + static wxIcon folderIcon; + + static bool isInitalized = false; + if (!isInitalized) + { + isInitalized = true; + + SHFILEINFO fileInfo; + fileInfo.hIcon = 0; //initialize hIcon + + //NOTE: CoInitializeEx()/CoUninitialize() implicitly called by wxWidgets on program startup! + if (::SHGetFileInfo(DefaultStr("dummy"), //Windows Seven doesn't like this parameter to be an empty string + FILE_ATTRIBUTE_DIRECTORY, + &fileInfo, + sizeof(fileInfo), + SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES) && + + fileInfo.hIcon != 0) //fix for weird error: SHGetFileInfo() might return successfully WITHOUT filling fileInfo.hIcon!! + { + folderIcon.SetHICON(fileInfo.hIcon); + folderIcon.SetSize(IconBuffer::ICON_SIZE, IconBuffer::ICON_SIZE); + } + } + return folderIcon; +} + +namespace +{ +Zstring getFileExtension(const Zstring& filename) +{ + const Zstring shortName = filename.AfterLast(DefaultChar('\\')); //Zstring::AfterLast() returns the whole string if ch not found + const size_t pos = shortName.Find(DefaultChar('.'), true); + return pos == Zstring::npos ? + Zstring() : + Zstring(shortName.c_str() + pos + 1); +} + + +struct CmpFilenameWin +{ + bool operator()(const Zstring& a, const Zstring& b) const + { + return a.CmpNoCase(b) < 0; + } +}; + + +//test for extension for icons that physically have to be retrieved from disc +bool isPriceyExtension(const Zstring& extension) +{ + static std::set<Zstring, CmpFilenameWin> exceptions; + static bool isInitalized = false; + if (!isInitalized) + { + isInitalized = true; + exceptions.insert(DefaultStr("exe")); + exceptions.insert(DefaultStr("lnk")); + exceptions.insert(DefaultStr("ico")); + exceptions.insert(DefaultStr("ani")); + exceptions.insert(DefaultStr("cur")); + exceptions.insert(DefaultStr("url")); + exceptions.insert(DefaultStr("msc")); + exceptions.insert(DefaultStr("scr")); + } + return exceptions.find(extension) != exceptions.end(); +} +} +//################################################################################################################################################ + typedef std::vector<DefaultChar> BasicString; //simple thread safe string class: std::vector is guaranteed to not use reference counting, Effective STL, item 13 @@ -112,7 +184,7 @@ wxThread::ExitCode WorkerThread::Entry() if (threadExitIsRequested) //no mutex here: atomicity is not prob for a bool, but visibility (e.g. caching in registers) return 0; //shouldn't be a problem nevertheless because of implicit memory barrier caused by mutex.Lock() in .Wait() - //do work: get the file icon. + //do work: get the file icons doWork(); } } @@ -139,29 +211,25 @@ void WorkerThread::doWork() workload.pop_back(); } - if (iconBuffer->requestIcon(Zstring(&fileName[0]))) //thread safety: Zstring okay, won't be reference-counted in requestIcon(), fileName is NOT empty - break; //icon already in buffer: enter waiting state + if (iconBuffer->requestFileIcon(Zstring(&fileName[0]))) //thread safety: Zstring okay, won't be reference-counted in requestIcon(), fileName is NOT empty + continue; //icon already in buffer: skip //despite what docu says about SHGetFileInfo() it can't handle all relative filenames, e.g. "\DirName" - const unsigned int MAX_SIZE = 10000; - DefaultChar fullName[MAX_SIZE]; - const DWORD rv = ::GetFullPathName( - &fileName[0], //__in LPCTSTR lpFileName, - MAX_SIZE, //__in DWORD nBufferLength, - fullName, //__out LPTSTR lpBuffer, - NULL); //__out LPTSTR *lpFilePart - if (rv < MAX_SIZE && rv != 0) - { - //load icon - SHFILEINFO fileInfo; - fileInfo.hIcon = 0; //initialize hIcon + //but no problem, directory formatting takes care that filenames are always absolute! - if (::SHGetFileInfo(fullName, //NOTE: CoInitializeEx()/CoUninitialize() implicitly called by wxWidgets on program startup! + //load icon + SHFILEINFO fileInfo; + fileInfo.hIcon = 0; //initialize hIcon + + const Zstring extension = getFileExtension(&fileName[0]); //thread-safe: no sharing! + if (isPriceyExtension(extension)) //"pricey" extensions are stored with fullnames and are read from disk, while cheap ones require just the extension + { + //NOTE: CoInitializeEx()/CoUninitialize() implicitly called by wxWidgets on program startup! + if (::SHGetFileInfo(&fileName[0], //FreeFileSync::removeLongPathPrefix(&fileName[0]), //::SHGetFileInfo() can't handle \\?\-prefix! 0, &fileInfo, sizeof(fileInfo), SHGFI_ICON | SHGFI_SMALLICON) && - fileInfo.hIcon != 0) //fix for weird error: SHGetFileInfo() might return successfully WITHOUT filling fileInfo.hIcon!! { //bug report: https://sourceforge.net/tracker/?func=detail&aid=2768004&group_id=234430&atid=1093080 @@ -170,7 +238,8 @@ void WorkerThread::doWork() newIcon.SetHICON(fileInfo.hIcon); newIcon.SetSize(IconBuffer::ICON_SIZE, IconBuffer::ICON_SIZE); - iconBuffer->insertIntoBuffer(&fileName[0], newIcon); //thread safety: icon may be deleted only within insertIntoBuffer() + iconBuffer->insertIntoBuffer(&fileName[0], newIcon); //thread safety: icon buffer is written by this thread and this call only, so + //newIcon can safely go out of scope without race-condition because of ref-counting //freeing of icon handle seems to happen somewhere beyond wxIcon destructor //if (!DestroyIcon(fileInfo.hIcon)) @@ -178,16 +247,32 @@ void WorkerThread::doWork() continue; } } + else //no read-access to disk! determine icon by extension + { + if (::SHGetFileInfo((Zstring(DefaultStr("dummy.")) + extension).c_str(), //Windows Seven doesn't like this parameter to be without short name + FILE_ATTRIBUTE_NORMAL, + &fileInfo, + sizeof(fileInfo), + SHGFI_ICON | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES) && + fileInfo.hIcon != 0) //fix for weird error: SHGetFileInfo() might return successfully WITHOUT filling fileInfo.hIcon!! + { + wxIcon newIcon; //attention: wxIcon uses reference counting! + newIcon.SetHICON(fileInfo.hIcon); + newIcon.SetSize(IconBuffer::ICON_SIZE, IconBuffer::ICON_SIZE); + + iconBuffer->insertIntoBuffer(extension.c_str(), newIcon); //thread safety: icon buffer is written by this thread and this call only, so + continue; + } + } + //if loading of icon fails for whatever reason, just save a dummy icon to avoid re-loading iconBuffer->insertIntoBuffer(&fileName[0], wxNullIcon); } } //--------------------------------------------------------------------------------------------------- - -typedef Zstring FileName; -class IconDB : public std::map<FileName, wxIcon> {}; -class IconDbSequence : public std::queue<FileName> {}; +class IconDB : public std::map<Zstring, wxIcon> {}; // entryName/icon +class IconDbSequence : public std::queue<Zstring> {}; // entryName //--------------------------------------------------------------------------------------------------- @@ -213,11 +298,16 @@ IconBuffer::~IconBuffer() } -bool IconBuffer::requestIcon(const Zstring& fileName, wxIcon* icon) +bool IconBuffer::requestFileIcon(const Zstring& fileName, wxIcon* icon) { + const Zstring extension = getFileExtension(fileName); + wxCriticalSectionLocker dummy(*lockIconDB); - IconDB::const_iterator i = buffer->find(fileName); + IconDB::const_iterator i = buffer->find( //"pricey" extensions are stored with fullnames and are read from disk, while cheap ones require just the extension + isPriceyExtension(extension) ? + fileName : + extension); if (i != buffer->end()) { if (icon != NULL) @@ -235,13 +325,13 @@ void IconBuffer::setWorkload(const std::vector<Zstring>& load) } -void IconBuffer::insertIntoBuffer(const DefaultChar* fileName, const wxIcon& icon) //called by worker thread +void IconBuffer::insertIntoBuffer(const DefaultChar* entryName, const wxIcon& icon) //called by worker thread { if (icon.IsOk()) //this check won't hurt { wxCriticalSectionLocker dummy(*lockIconDB); - const Zstring fileNameZ = fileName; + const Zstring fileNameZ = entryName; const std::pair<IconDB::iterator, bool> rc = buffer->insert(IconDB::value_type(fileNameZ, icon)); @@ -260,3 +350,6 @@ void IconBuffer::insertIntoBuffer(const DefaultChar* fileName, const wxIcon& ico } } + + + diff --git a/library/iconBuffer.h b/library/iconBuffer.h index e6d2bcaf..703f7eb7 100644 --- a/library/iconBuffer.h +++ b/library/iconBuffer.h @@ -25,10 +25,12 @@ class IconBuffer public: static IconBuffer& getInstance(); - bool requestIcon(const Zstring& fileName, wxIcon* icon = NULL); //returns false if icon is not in buffer + static const wxIcon& getDirectoryIcon(); //one folder icon should be sufficient... + + bool requestFileIcon(const Zstring& fileName, wxIcon* icon = NULL); //returns false if icon is not in buffer void setWorkload(const std::vector<Zstring>& load); //(re-)set new workload of icons to be retrieved; - static const int ICON_SIZE = 16; //size in pixel + static const int ICON_SIZE = 16; //size in pixel static const size_t BUFFER_SIZE = 800; //maximum number if icons to buffer private: @@ -36,7 +38,7 @@ private: ~IconBuffer(); //methods used by worker thread - void insertIntoBuffer(const DefaultChar* fileName, const wxIcon& icon); + void insertIntoBuffer(const DefaultChar* entryName, const wxIcon& icon); //---------------------- Shared Data ------------------------- std::auto_ptr<wxCriticalSection> lockIconDB; diff --git a/library/processXml.cpp b/library/processXml.cpp index af16f91e..4773fb72 100644 --- a/library/processXml.cpp +++ b/library/processXml.cpp @@ -416,6 +416,9 @@ void FfsXmlParser::readXmlGlobalSettings(xmlAccess::XmlGlobalSettings& outputCfg //last update check readXmlElementLogging("LastCheckForUpdates", global, outputCfg.lastUpdateCheck); + //minimum size (in bytes) for files to be considered for rename-detection + readXmlElementLogging("DetectRenameThreshold", global, outputCfg.detectRenameThreshold); + const TiXmlElement* optionalDialogs = TiXmlHandleConst(root).FirstChild("Shared").FirstChild("ShowOptionalDialogs").ToElement(); @@ -814,6 +817,9 @@ bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& inputCfg, TiXmlD //last update check addXmlElement("LastCheckForUpdates", inputCfg.lastUpdateCheck, global); + //minimum size (in bytes) for files to be considered for rename-detection + addXmlElement("DetectRenameThreshold", inputCfg.detectRenameThreshold, global); + //optional dialogs TiXmlElement* optionalDialogs = new TiXmlElement("ShowOptionalDialogs"); diff --git a/library/processXml.h b/library/processXml.h index 80db71a3..9cb920d9 100644 --- a/library/processXml.h +++ b/library/processXml.h @@ -109,12 +109,15 @@ struct XmlGlobalSettings programLanguage(retrieveSystemLanguage()), ignoreOneHourDiff(false), copyLockedFiles(true), - lastUpdateCheck(0) {} + detectRenameThreshold(1024 *1024), + lastUpdateCheck(0) + {} int programLanguage; - bool ignoreOneHourDiff; //ignore +/- 1 hour due to DST change - bool copyLockedFiles; //VSS usage - long lastUpdateCheck; //time of last update check + bool ignoreOneHourDiff; //ignore +/- 1 hour due to DST change + bool copyLockedFiles; //VSS usage + unsigned int detectRenameThreshold; //minimum size (in bytes) for files to be considered for rename-detection + long lastUpdateCheck; //time of last update check OptionalDialogs optDialogs; diff --git a/library/resources.cpp b/library/resources.cpp index 02f5d701..3b44a361 100644 --- a/library/resources.cpp +++ b/library/resources.cpp @@ -21,164 +21,6 @@ const GlobalResources& GlobalResources::getInstance() GlobalResources::GlobalResources() { - //map, allocate and initialize pictures - bitmapResource[wxT("CmpByTime.png")] = (bitmapCmpByTime = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("CmpByContent.png")] = (bitmapCmpByContent = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("left arrow.png")] = (bitmapArrowLeft = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("right arrow.png")] = (bitmapArrowRight = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("left arrow create.png")] = (bitmapArrowLeftCr = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("right arrow create.png")] = (bitmapArrowRightCr = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("no arrow.png")] = (bitmapArrowNone = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("start sync.png")] = (bitmapStartSync = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("start sync dis.png")] = (bitmapStartSyncDis = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("left delete.png")] = (bitmapDeleteLeft = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("right delete.png")] = (bitmapDeleteRight = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("email.png")] = (bitmapEmail = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("about.png")] = (bitmapAbout = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("about_small.png")] = (bitmapAboutSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("website.png")] = (bitmapWebsite = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("exit.png")] = (bitmapExit = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("compare.png")] = (bitmapCompare = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("compare disabled.png")] = (bitmapCompareDisabled = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("sync.png")] = (bitmapSync = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("sync disabled.png")] = (bitmapSyncDisabled = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("swap.png")] = (bitmapSwap = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("swap_slim.png")] = (bitmapSwapSlim = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("help.png")] = (bitmapHelp = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftOnly.png")] = (bitmapLeftOnly = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftOnlyAct.png")] = (bitmapLeftOnlyAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftOnlyDeact.png")] = (bitmapLeftOnlyDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightOnly.png")] = (bitmapRightOnly = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightOnlyAct.png")] = (bitmapRightOnlyAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightOnlyDeact.png")] = (bitmapRightOnlyDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftNewer.png")] = (bitmapLeftNewer = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftNewerAct.png")] = (bitmapLeftNewerAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftNewerDeact.png")] = (bitmapLeftNewerDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightNewer.png")] = (bitmapRightNewer = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightNewerAct.png")] = (bitmapRightNewerAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightNewerDeact.png")] = (bitmapRightNewerDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("different.png")] = (bitmapDifferent = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("differentAct.png")] = (bitmapDifferentAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("differentDeact.png")] = (bitmapDifferentDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("equal.png")] = (bitmapEqual = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("equalAct.png")] = (bitmapEqualAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("equalDeact.png")] = (bitmapEqualDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("conflict.png")] = (bitmapConflict = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("conflictGrey.png")] = (bitmapConflictGrey = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("conflictAct.png")] = (bitmapConflictAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("conflictDeact.png")] = (bitmapConflictDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("include.png")] = (bitmapInclude = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("exclude.png")] = (bitmapExclude = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("filter active.png")] = (bitmapFilterOn = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("filter not active.png")] = (bitmapFilterOff = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("filter_small.png")] = (bitmapFilterSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("filterSmallGrey.png")] = (bitmapFilterSmallGrey = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("warning.png")] = (bitmapWarning = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("warningSmall.png")] = (bitmapWarningSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("error.png")] = (bitmapError = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("small arrow up.png"]) = (bitmapSmallUp = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("small arrow down.png")] = (bitmapSmallDown = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("save.png")] = (bitmapSave = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("load.png")] = (bitmapLoad = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("saveSmall.png")] = (bitmapSaveSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("loadSmall.png")] = (bitmapLoadSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("newSmall.png")] = (bitmapNewSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("FreeFileSync.png")] = (bitmapFFS = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("deleteFile.png")] = (bitmapDeleteFile = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("gpl.png")] = (bitmapGPL = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusPause.png")] = (bitmapStatusPause = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusError.png")] = (bitmapStatusError = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusSuccess.png")] = (bitmapStatusSuccess = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusWarning.png")] = (bitmapStatusWarning = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusScanning.png")] = (bitmapStatusScanning = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusBinaryCompare.png")]= (bitmapStatusBinCompare = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusSyncing.png")] = (bitmapStatusSyncing = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("logo.png")] = (bitmapLogo = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("statusEdge.png")] = (bitmapStatusEdge = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("add pair.png")] = (bitmapAddFolderPair = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("remove pair.png")] = (bitmapRemoveFolderPair = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("remove pair disabl.png")] = (bitmapRemoveFolderPairD = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("link.png")] = (bitmapLink = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("background.png")] = (bitmapBackground = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("compare_small.png")] = (bitmapCompareSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("sync_small.png")] = (bitmapSyncSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("clock_small.png")] = (bitmapClockSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("clock.png")] = (bitmapClock = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("batch.png")] = (bitmapBatch = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("batch_small.png")] = (bitmapBatchSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("move up.png")] = (bitmapMoveUp = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("move down.png")] = (bitmapMoveDown = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("checkbox_true.png")] = (bitmapCheckBoxTrue = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("checkbox_true_focus.png")] = (bitmapCheckBoxTrueFocus = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("checkbox_false.png")] = (bitmapCheckBoxFalse = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("checkbox_false_focus.png")] = (bitmapCheckBoxFalseFocus = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("settings.png")] = (bitmapSettings = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("settings_small.png")] = (bitmapSettingsSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("recycler.png")] = (bitmapRecycler = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("shift.png")] = (bitmapShift = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncConfig.png")] = (bitmapSyncCfg = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncConfigSmall.png")] = (bitmapSyncCfgSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncConfigSmallGrey.png")] = (bitmapSyncCfgSmallGrey = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("cmpConfig.png")] = (bitmapCmpCfg = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncPreview.png")] = (bitmapPreview = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncPreviewDisabl.png")] = (bitmapPreviewDisabled = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("question.png")] = (bitmapQuestion = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("czechRep.png")] = (bitmapCzechRep = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("china.png")] = (bitmapChina = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("holland.png")] = (bitmapHolland = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("england.png")] = (bitmapEngland = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("france.png")] = (bitmapFrance = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("finland.png")] = (bitmapFinland = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("germany.png")] = (bitmapGermany = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("hungary.png")] = (bitmapHungary = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("romania.png")] = (bitmapRomania = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("taiwan.png")] = (bitmapTaiwan = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("turkey.png")] = (bitmapTurkey = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("italy.png")] = (bitmapItaly = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("japan.png")] = (bitmapJapan = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("poland.png")] = (bitmapPoland = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("portugal.png")] = (bitmapPortugal = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("brazil.png")] = (bitmapBrazil = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("slovakia.png")] = (bitmapSlovakia = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("spain.png")] = (bitmapSpain = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("russia.png")] = (bitmapRussia = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncCreateLeftAct.png")] = (bitmapSyncCreateLeftAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncCreateLeftDeact.png")] = (bitmapSyncCreateLeftDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncCreateRightAct.png")] = (bitmapSyncCreateRightAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncCreateRightDeact.png")] = (bitmapSyncCreateRightDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDeleteLeftAct.png")] = (bitmapSyncDeleteLeftAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDeleteLeftDeact.png")] = (bitmapSyncDeleteLeftDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDeleteRightAct.png")] = (bitmapSyncDeleteRightAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDeleteRightDeact.png")] = (bitmapSyncDeleteRightDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirLeftAct.png")] = (bitmapSyncDirLeftAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirLeftDeact.png")] = (bitmapSyncDirLeftDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirRightAct.png")] = (bitmapSyncDirRightAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirRightDeact.png")] = (bitmapSyncDirRightDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirNoneAct.png")] = (bitmapSyncDirNoneAct = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirNoneDeact.png")] = (bitmapSyncDirNoneDeact = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirLeftSmall.png")] = (bitmapSyncDirLeftSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirRightSmall.png")] = (bitmapSyncDirRightSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncDirNoneSmall.png")] = (bitmapSyncDirNoneSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("createLeftSmall.png")] = (bitmapCreateLeftSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("createRightSmall.png")] = (bitmapCreateRightSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("deleteLeftSmall.png")] = (bitmapDeleteLeftSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("deleteRightSmall.png")] = (bitmapDeleteRightSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftOnlySmall.png")] = (bitmapLeftOnlySmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightOnlySmall.png")] = (bitmapRightOnlySmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("leftNewerSmall.png")] = (bitmapLeftNewerSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("rightNewerSmall.png")] = (bitmapRightNewerSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("equalSmall.png")] = (bitmapEqualSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("differentSmall.png")] = (bitmapDifferentSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("conflictSmall.png")] = (bitmapConflictSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("create.png")] = (bitmapCreate = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("update.png")] = (bitmapUpdate = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("delete.png")] = (bitmapDelete = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("data.png")] = (bitmapData = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("cmpViewSmall.png")] = (bitmapCmpViewSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("syncViewSmall.png")] = (bitmapSyncViewSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("toggleViewSmall.png")] = (bitmapSwitchViewSmall = new wxBitmap(wxNullBitmap)); - - //init all the other resource files animationMoney = new wxAnimation(wxNullAnimation); animationSync = new wxAnimation(wxNullAnimation); @@ -227,7 +69,6 @@ void GlobalResources::load() const wxZipInputStream resourceFile(input); - std::map<wxString, wxBitmap*>::iterator bmp; while (true) { std::auto_ptr<wxZipEntry> entry(resourceFile.GetNextEntry()); @@ -236,9 +77,12 @@ void GlobalResources::load() const const wxString name = entry->GetName(); - //search if entry is available in map - if ((bmp = bitmapResource.find(name)) != bitmapResource.end()) - *(bmp->second) = wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG)); + //generic image loading + if (name.EndsWith(wxT(".png"))) + { + if (bitmapResource.find(name) == bitmapResource.end()) //avoid duplicate entry: prevent memory leak! + bitmapResource[name] = new wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG)); + } else if (name == wxT("money.gif")) loadAnimFromZip(resourceFile, animationMoney); else if (name == wxT("working.gif")) @@ -253,15 +97,18 @@ void GlobalResources::load() const //#include "FreeFileSync.xpm" //*programIcon = wxIcon(FreeFileSync_xpm); - //use big FFS logo bitmap for better quality - programIcon->CopyFromBitmap(*bitmapFFS); + //use big logo bitmap for better quality + programIcon->CopyFromBitmap(getImageByName(wxT("FreeFileSync.png"))); #endif } const wxBitmap& GlobalResources::getImageByName(const wxString& imageName) const { - std::map<wxString, wxBitmap*>::const_iterator bmp = bitmapResource.find(imageName); + const std::map<wxString, wxBitmap*>::const_iterator bmp = imageName.Find(wxChar('.')) == wxNOT_FOUND ? //assume .png ending if nothing else specified + bitmapResource.find(imageName + wxT(".png")) : + bitmapResource.find(imageName); + if (bmp != bitmapResource.end()) return *bmp->second; else diff --git a/library/resources.h b/library/resources.h index 512d7ed9..c6424dbb 100644 --- a/library/resources.h +++ b/library/resources.h @@ -14,166 +14,9 @@ public: const wxBitmap& getImageByName(const wxString& imageName) const; - //image resource objects - wxBitmap* bitmapCmpByTime; - wxBitmap* bitmapCmpByContent; - wxBitmap* bitmapArrowLeft; - wxBitmap* bitmapArrowRight; - wxBitmap* bitmapArrowLeftCr; - wxBitmap* bitmapArrowRightCr; - wxBitmap* bitmapArrowNone; - wxBitmap* bitmapStartSync; - wxBitmap* bitmapStartSyncDis; - wxBitmap* bitmapDeleteLeft; - wxBitmap* bitmapDeleteRight; - wxBitmap* bitmapEmail; - wxBitmap* bitmapAbout; - wxBitmap* bitmapAboutSmall; - wxBitmap* bitmapWebsite; - wxBitmap* bitmapExit; - wxBitmap* bitmapCompare; - wxBitmap* bitmapCompareDisabled; - wxBitmap* bitmapSync; - wxBitmap* bitmapSyncDisabled; - wxBitmap* bitmapSwap; - wxBitmap* bitmapSwapSlim; - wxBitmap* bitmapHelp; - wxBitmap* bitmapLeftOnly; - wxBitmap* bitmapLeftOnlyAct; - wxBitmap* bitmapLeftOnlyDeact; - wxBitmap* bitmapRightOnly; - wxBitmap* bitmapRightOnlyAct; - wxBitmap* bitmapRightOnlyDeact; - wxBitmap* bitmapLeftNewer; - wxBitmap* bitmapLeftNewerAct; - wxBitmap* bitmapLeftNewerDeact; - wxBitmap* bitmapRightNewer; - wxBitmap* bitmapRightNewerAct; - wxBitmap* bitmapRightNewerDeact; - wxBitmap* bitmapEqual; - wxBitmap* bitmapEqualAct; - wxBitmap* bitmapEqualDeact; - wxBitmap* bitmapDifferent; - wxBitmap* bitmapDifferentAct; - wxBitmap* bitmapDifferentDeact; - wxBitmap* bitmapConflict; - wxBitmap* bitmapConflictGrey; - wxBitmap* bitmapConflictAct; - wxBitmap* bitmapConflictDeact; - wxBitmap* bitmapInclude; - wxBitmap* bitmapExclude; - wxBitmap* bitmapFilterOn; - wxBitmap* bitmapFilterOff; - wxBitmap* bitmapFilterSmall; - wxBitmap* bitmapFilterSmallGrey; - wxBitmap* bitmapWarning; - wxBitmap* bitmapWarningSmall; - wxBitmap* bitmapError; - wxBitmap* bitmapSmallUp; - wxBitmap* bitmapSmallDown; - wxBitmap* bitmapSave; - wxBitmap* bitmapLoad; - wxBitmap* bitmapSaveSmall; - wxBitmap* bitmapLoadSmall; - wxBitmap* bitmapNewSmall; - wxBitmap* bitmapFFS; - wxBitmap* bitmapDeleteFile; - wxBitmap* bitmapGPL; - wxBitmap* bitmapStatusPause; - wxBitmap* bitmapStatusError; - wxBitmap* bitmapStatusSuccess; - wxBitmap* bitmapStatusWarning; - wxBitmap* bitmapStatusScanning; - wxBitmap* bitmapStatusBinCompare; - wxBitmap* bitmapStatusSyncing; - wxBitmap* bitmapLogo; - wxBitmap* bitmapStatusEdge; - wxBitmap* bitmapAddFolderPair; - wxBitmap* bitmapRemoveFolderPair; - wxBitmap* bitmapRemoveFolderPairD; - wxBitmap* bitmapLink; - wxBitmap* bitmapBackground; - wxBitmap* bitmapCompareSmall; - wxBitmap* bitmapSyncSmall; - wxBitmap* bitmapClockSmall; - wxBitmap* bitmapClock; - wxBitmap* bitmapBatch; - wxBitmap* bitmapBatchSmall; - wxBitmap* bitmapMoveUp; - wxBitmap* bitmapMoveDown; - wxBitmap* bitmapCheckBoxTrue; - wxBitmap* bitmapCheckBoxTrueFocus; - wxBitmap* bitmapCheckBoxFalse; - wxBitmap* bitmapCheckBoxFalseFocus; - wxBitmap* bitmapSettings; - wxBitmap* bitmapSettingsSmall; - wxBitmap* bitmapRecycler; - wxBitmap* bitmapShift; - wxBitmap* bitmapSyncCfg; - wxBitmap* bitmapSyncCfgSmall; - wxBitmap* bitmapSyncCfgSmallGrey; - wxBitmap* bitmapCmpCfg; - wxBitmap* bitmapPreview; - wxBitmap* bitmapPreviewDisabled; - wxBitmap* bitmapQuestion; - wxBitmap* bitmapCzechRep; - wxBitmap* bitmapChina; - wxBitmap* bitmapHolland; - wxBitmap* bitmapEngland; - wxBitmap* bitmapFrance; - wxBitmap* bitmapFinland; - wxBitmap* bitmapGermany; - wxBitmap* bitmapHungary; - wxBitmap* bitmapRomania; - wxBitmap* bitmapTaiwan; - wxBitmap* bitmapTurkey; - wxBitmap* bitmapItaly; - wxBitmap* bitmapJapan; - wxBitmap* bitmapPoland; - wxBitmap* bitmapPortugal; - wxBitmap* bitmapBrazil; - wxBitmap* bitmapSlovakia; - wxBitmap* bitmapSpain; - wxBitmap* bitmapRussia; - wxBitmap* bitmapSyncCreateLeftAct; - wxBitmap* bitmapSyncCreateLeftDeact; - wxBitmap* bitmapSyncCreateRightAct; - wxBitmap* bitmapSyncCreateRightDeact; - wxBitmap* bitmapSyncDeleteLeftAct; - wxBitmap* bitmapSyncDeleteLeftDeact; - wxBitmap* bitmapSyncDeleteRightAct; - wxBitmap* bitmapSyncDeleteRightDeact; - wxBitmap* bitmapSyncDirLeftAct; - wxBitmap* bitmapSyncDirLeftDeact; - wxBitmap* bitmapSyncDirRightAct; - wxBitmap* bitmapSyncDirRightDeact; - wxBitmap* bitmapSyncDirNoneAct; - wxBitmap* bitmapSyncDirNoneDeact; - wxBitmap* bitmapSyncDirLeftSmall; - wxBitmap* bitmapSyncDirRightSmall; - wxBitmap* bitmapSyncDirNoneSmall; - wxBitmap* bitmapCreateLeftSmall; - wxBitmap* bitmapCreateRightSmall; - wxBitmap* bitmapDeleteLeftSmall; - wxBitmap* bitmapDeleteRightSmall; - wxBitmap* bitmapLeftOnlySmall; - wxBitmap* bitmapRightOnlySmall; - wxBitmap* bitmapLeftNewerSmall; - wxBitmap* bitmapRightNewerSmall; - wxBitmap* bitmapEqualSmall; - wxBitmap* bitmapDifferentSmall; - wxBitmap* bitmapConflictSmall; - wxBitmap* bitmapCreate; - wxBitmap* bitmapUpdate; - wxBitmap* bitmapDelete; - wxBitmap* bitmapData; - wxBitmap* bitmapCmpViewSmall; - wxBitmap* bitmapSyncViewSmall; - wxBitmap* bitmapSwitchViewSmall; - + //global image resource objects wxAnimation* animationMoney; wxAnimation* animationSync; - wxIcon* programIcon; void load() const; //loads bitmap resources on program startup: logical const! diff --git a/library/statistics.cpp b/library/statistics.cpp index 53a75fce..f4319686 100644 --- a/library/statistics.cpp +++ b/library/statistics.cpp @@ -113,10 +113,10 @@ Statistics::Statistics(const int totalObjectCount, remainingTimeLast(256*256*256*100), //something "big" timer(new wxStopWatch) {} - Statistics::~Statistics() - { - delete timer; - } +Statistics::~Statistics() +{ + delete timer; +} void Statistics::addMeasurement(const int objectsCurrent, const double dataCurrent) { diff --git a/library/statistics.h b/library/statistics.h index d1b8b98b..a8aa140f 100644 --- a/library/statistics.h +++ b/library/statistics.h @@ -39,7 +39,7 @@ public: const unsigned windowSizeRemainingTime, //time in ms const unsigned windowSizeBytesPerSecond); //time in ms - ~Statistics(); + ~Statistics(); void addMeasurement(const int objectsCurrent, const double dataCurrent); wxString getRemainingTime() const; //returns the remaining time in milliseconds |