Adding IDC Handler - fails

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
MaC-GyVer
Posts: 4
Joined: 2004-07-02 09:46

Adding IDC Handler - fails

Post by MaC-GyVer » 2004-07-02 10:11

Hi!
First of all I would like to say that DC++ is a one of a kind p2p client.
Having that said, I feel I could add just 2 or 3 features to make it perfect :D

Now, the problem is, that I am a newbie C++ programmer.
I have been into PHP, ASP and CGI so I am not completly blind :wink:

So, after a few tries, I managed to compile DC++ v403.
My first reaction was more like : :?: because of the bit amount of files.
But after a I had seen the source code, I't really was not that bad, and when It all was made so systematic I could actually understand a bit :P

Therefore I started to try on my own, but began to fail and fail and fail.
I searched the forums for help, but could not find anything interesting for my purpose.

What I tried to do, was adding a command at the TransferView.cpp with this line :

Code: Select all

transferMenu.AppendMenu(MF_STRING, IDC_OPEN, CSTRING(OPEN_FILE));
and added this in the TransferView.h file :

Code: Select all

COMMAND_ID_HANDLER(IDC_OPEN, onRemove) // Im not skilled enough to make my own function yet
Obvious this does not work, when compiling an error like :
c:\DC Source\windows\TransferView.cpp(74) : error C2039: 'OPEN_FILE' : is not a member of 'ResourceManager'
c:\DC Source\client\ResourceManager.h(28) : see declaration of 'ResourceManager'
So, only idea I got, is to find the ResourceManager.h file and try to add the OPEN_FILE "thing" :P. But there, ofcourse, I cant find nothing to do with TransferView.cpp (I'm Sure it is a combinding, but I can not see it).
But then I notice the :

Code: Select all

#include "StringDefs.h"
So I enter the file and see the other TransferView.h COMMAND_ID_HANDLER mates :P
Then, I add OPEN_FILE but STILL I get a compile error.
Only change is now the ResourceManager.h error is gone, and I got :

Code: Select all

c:\DC Source\windows\TransferView.h(61) : error C2059: syntax error : '=='
c:\DC Source\windows\TransferView.h(61) : error C2143: syntax error : missing ';' before '{'
c:\DC Source\windows\TransferView.cpp(74) : error C2059: syntax error : ','
Left.. Can someone PLEASE HELP!? :roll:

psf8500
Posts: 23
Joined: 2003-03-04 18:51
Contact:

Post by psf8500 » 2004-07-02 10:36

You were on the right track with StringDefs. This link may help you with that.

A quick solution might be to just do this:

Code: Select all

transferMenu.AppendMenu(MF_STRING, IDC_OPEN, "Open file");

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-07-02 10:42

MaC-GyVer, would you mind posting the lines in the source file that the compiler is choking on? That would help us help you. :)

MakeDefs (and md.cmd which is in the client\ directory in the zipped source) is very useful when adding a string - it recreates stringdefs.cpp and example.xml for you.

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Re: Adding IDC Handler - fails

Post by GargoyleMT » 2004-07-02 11:01

MaC-GyVer wrote:My first reaction was more like : :?: because of the bit amount of files.
For comparison sake, I suggest you take a look at http://sourceforge.net/projects/shareaza/ (the code is in CVS, or on their website), all 672 files are in one directory. :-D

MaC-GyVer
Posts: 4
Joined: 2004-07-02 09:46

Post by MaC-GyVer » 2004-07-03 14:38

Thank you very much for even trying to help me :D .
On most forums like this no one even bother to read your post :)

But, anyway, here is the code the compiler is stucking on :

Code: Select all

COMMAND_ID_HANDLER(IDC_OPEN, onRemove)
and

Code: Select all

transferMenu.AppendMenu(MF_STRING, IDC_OPEN, CSTRING(OPEN_FILE));
these two erros is displayed as this errors in the compiler :

Code: Select all

TransferView.cpp
c:\DC Source\windows\TransferView.h(61) : error C2059: syntax error : '==' // with this being the first code
c:\DC Source\windows\TransferView.h(61) : error C2143: syntax error : missing ';' before '{'
c:\DC Source\windows\TransferView.cpp(74) : error C2059: syntax error : ',' / and this being the second code
So, if someone could help me out on this, it would really make my day :P

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2004-07-03 23:59

How have you defined IDC_OPEN?

MaC-GyVer
Posts: 4
Joined: 2004-07-02 09:46

Post by MaC-GyVer » 2004-07-04 07:15

I defined IDC_OPEN by open the file "resource.h" and scrolling down to the buttom
and added

Code: Select all

#define IDC_OPEN

Right befor the comment : // Next default values for new objects
I did not add any number tough. That may cause the compile error ?

And again, thanks for helping me out on this!'

[EDIT :
I finally got the function to work, now the problem is, that the place where I have put "Remove from Queue" text, is blank now. I can still push the blank "button" and my action will take place. Any ideas on how to get the text appearing ?]
[ANOTHER EDIT :
YAY, got that one also to work. I just added

Code: Select all

transferMenu.AppendMenu(MF_STRING, IDC_OPEN, "Open File");
.
But, I would like to know anyways how you add text by CSTRING , so I can hold the "example.xml" standard]

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-07-04 20:05

You definitely need a number for that resource ID. You can manually enter a new ID with the file, or to do it with the GUI, go to the resource editor pane, open til you see DCPlusPlus.rc, then right click there and pick the Resource Symbols option. I think you can get out of sync with the _APS_NEXT values by doing it this way.

To add a new string, make the MakeDefs project through the context menu on the project window, copy MakeDefs.exe to the root of your DC++ source directory, Edit StringDefs.h, then run md.cmd in the client\ subdirectory.

A diff of your files should look something like this:

Code: Select all

diff -urd DCPlusPlus-cvs.orig/client/StringDefs.h DCPlusPlus-cvs/client/StringDefs.h
--- DCPlusPlus-cvs.orig/client/StringDefs.h	Sun Jun 27 13:03:03 2004
+++ DCPlusPlus-cvs/client/StringDefs.h	Sun Jul  4 20:59:28 2004
@@ -228,6 +230,7 @@
 	ONLY_WHERE_OP, // "Only where I'm op"
 	OPEN, // "Open"
 	OPEN_DOWNLOAD_PAGE, // "Open download page?"
+	OPEN_FILE, // "Open File"
 	OPEN_FOLDER, // "Open folder"
 	OPERATION_WOULD_BLOCK_EXECUTION, // "Operation would block execution"
 	OUT_OF_BUFFER_SPACE, // "Out of buffer space"
diff -urd DCPlusPlus-cvs.orig/client/StringDefs.cpp DCPlusPlus-cvs/client/StringDefs.cpp
--- DCPlusPlus-cvs.orig/client/StringDefs.cpp	Sun Jun 27 13:03:03 2004
+++ DCPlusPlus-cvs/client/StringDefs.cpp	Sun Jul  4 20:59:36 2004
@@ -225,6 +227,7 @@
 "Only where I'm op", 
 "Open", 
 "Open download page?", 
+"Open File", 
 "Open folder", 
 "Operation would block execution", 
 "Out of buffer space", 
@@ -659,6 +664,7 @@
 "OnlyWhereOp", 
 "Open", 
 "OpenDownloadPage", 
+"OpenFile", 
 "OpenFolder", 
 "OperationWouldBlockExecution", 
 "OutOfBufferSpace", 
diff -urd DCPlusPlus-cvs.orig/Example.xml DCPlusPlus-cvs/Example.xml
--- DCPlusPlus-cvs.orig/Example.xml	Sun Jun 27 13:03:00 2004
+++ DCPlusPlus-cvs/Example.xml	Sun Jul  4 20:59:36 2004
@@ -224,6 +226,7 @@
 		<String Name="OnlyWhereOp">Only where I'm op</String>
 		<String Name="Open">Open</String>
 		<String Name="OpenDownloadPage">Open download page?</String>
+		<String Name="OpenFile">Open File</String>
 		<String Name="OpenFolder">Open folder</String>
 		<String Name="OperationWouldBlockExecution">Operation would block execution</String>
 		<String Name="OutOfBufferSpace">Out of buffer space</String>
(Line numbers are off because that's from my DC++ workspace, where I'm planning some features. :))

Locked