So, I'm now able to compile the current version of DC++ (cheers to everyone who responded to my plea for help
I wanted to go for something obscure and out of the way that no-one would notice, so I picked the "Share Hidden" checkbox in the Sharing page. Obscure enough?
It started off as trying to fix a bug from the tracker but then I realised there was a deficiency on this page. If you add or remove a directory from your share, the share size is updated immediately in the GUI. The Share Hidden button does not do this though. You need to leave settings, manually refresh the share and then go back to settings to see the changes.
So I decided to try and implement that. And all hell broke loose. It was a spiralling nightmare, but I think I'm the better for it, seeing as this is the first time I've ever delved into a C++ project. It may only be a few lines of code, but it has helped me greatly with understanding of some of the inner workings of DC++ and also the use of C++.
"The point?" I hear you ask. Well basically, I just want someone to go over what I have done and see if there are any glaring errors in the way that I have done it. Plus any other constructive criticism.
So here is the code:
Code: Select all
diff -c DCPlusPlus-0.304-src/windows/UploadPage.cpp DC++/windows/UploadPage.cpp
*** DCPlusPlus-0.304-src/windows/UploadPage.cpp Mon Oct 27 18:10:54 2003
--- DC++/windows/UploadPage.cpp Fri Nov 21 22:50:39 2003
***************
*** 138,143 ****
--- 138,165 ----
return 0;
}
+ LRESULT UploadPage::onClickedShareHidden(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+ {
+ // Save this pages info so that ShareManager knows to include/disclude hidden files
+ PropPage::write((HWND)*this, items);
+ // Refresh the share. This is a blocking refresh. Might cause problems?
+ ShareManager::getInstance()->setDirty();
+ ShareManager::getInstance()->refresh(true, false, true);
+
+ // Clear the GUI list, for insertion of updated shares
+ ctrlDirectories.DeleteAllItems();
+ StringList directories = ShareManager::getInstance()->getDirectories();
+ for(StringIter j = directories.begin(); j != directories.end(); j++)
+ {
+ int i = ctrlDirectories.insert(ctrlDirectories.GetItemCount(), *j);
+ ctrlDirectories.SetItemText(i, 1, Util::formatBytes(ShareManager::getInstance()->getShareSize(*j)).c_str());
+ }
+
+ // Display the new total share size
+ ctrlTotal.SetWindowText(Util::formatBytes(ShareManager::getInstance()->getShareSize()).c_str());
+ return 0;
+ }
+
/**
* @file
* $Id: UploadPage.cpp,v 1.12 2003/10/27 17:10:53 arnetheduck Exp $Code: Select all
diff -c DCPlusPlus-0.304-src/windows/UploadPage.h DC++/windows/UploadPage.h
*** DCPlusPlus-0.304-src/windows/UploadPage.h Mon Oct 20 23:04:56 2003
--- DC++/windows/UploadPage.h Thu Nov 20 23:28:21 2003
***************
*** 42,53 ****
--- 42,55 ----
NOTIFY_HANDLER(IDC_DIRECTORIES, LVN_ITEMCHANGED, onItemchangedDirectories)
COMMAND_ID_HANDLER(IDC_ADD, onClickedAdd)
COMMAND_ID_HANDLER(IDC_REMOVE, onClickedRemove)
+ COMMAND_ID_HANDLER(IDC_SHAREHIDDEN, onClickedShareHidden)
END_MSG_MAP()
LRESULT onInitDialog(UINT, WPARAM, LPARAM, BOOL&);
LRESULT onItemchangedDirectories(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
LRESULT onClickedAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT onClickedRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+ LRESULT onClickedShareHidden(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// Common PropPage interface
PROPSHEETPAGE *getPSP() { return (PROPSHEETPAGE *)*this; }Cheers!