Thread: Help me with function call

  1. #16
    Registered User
    Join Date
    May 2008
    Posts
    52
    It may look a bit rude to give you the link to the source, but i dont know what kind of code you need to see to help me out, so you may download the source here:

    http://www.vidalia-project.net/dist/...a-0.1.2.tar.gz

    Untar that and focus your attention only to 3 files:

    main.cpp

    Here is where it all begins, here you can find the code line:
    Code:
      /* Create an instance of the main window  */
      MainWindow mainWin;
    With this i think he creates the main window, I'm not sure becuz I cant find the word "mainWin" being used in other file except this main.cpp

    mainwindow.cpp

    Here you find the definition of the function that i want to execute each 60 seconds with a timer or something:
    Code:
    void
    MainWindow::newIdentity()
    {
      QString errmsg;
    
      /* Send the NEWNYM signal. If message balloons are supported and the NEWNYM
       * is successful, we will show the result as a balloon. Otherwise, we'll 
       * just use a message box. */
      if (_torControl->signal(TorSignal::NewNym, &errmsg)) {
        /* NEWNYM signal was successful */
        QString title = tr("New Identity");
        QString message = tr("All subsequent connections will "
                             "appear to be different than your "
                             "old connections.");
    
        /* Disable the New Identity button for MIN_NEWIDENTITY_INTERVAL */
        _newIdentityAct->setEnabled(false);
        ui.lblNewIdentity->setEnabled(false);
        QTimer::singleShot(MIN_NEWIDENTITY_INTERVAL, 
                           this, SLOT(enableNewIdentity()));
    
        if (TrayIcon::supportsBalloonMessages())
          _trayIcon.showBalloonMessage(title, message, TrayIcon::Information);
        else
          VMessageBox::information(this, title, message, VMessageBox::Ok);
      } else {
        /* NEWNYM signal failed */
        VMessageBox::warning(this, 
          tr("Failed to Create New Identity"), errmsg, VMessageBox::Ok);
      }
    }
    I want to call this function somewhere else in the code where it runs each 60 seconds.
    I have 2 problems here:

    1st- I dont know if i should call with the name mainWin.newIdentity(), because it tells that mainWin is not declared, but it is declared from the main.cpp

    2nd- Where should i put that call or how could i configure a timer that calls that function using interruptions (it pauses what it is doing only to call that function, then he continues what he was doing before the call).


    The 3rd file:

    vidalia.cpp

    Here you find the declaration of the function Vidalia::run(), the 1st function called by the main.cpp, and when this function finish its execution, vidalia exits, i had the idea to put here the call routine, but i failed to do so...

    Ok that is all, this is the hell i'm passing by in this 3 last days.
    For a 1st open source coding experience this is being a little hard, but now i want to see how could i done it better, i want to learn with my mistakes.

    /////-----------------------

    Objective:
    So resuming, my objective is to call the function MainWindow::newIdentity() (xxxx.newIdentity() ) each 60 seconds, this way my IP would change each 60 seconds and I would not overload any proxy with so many connections (because i saw some proxies refusing so many connections when i have some 10 tabs opened in firefox lol).

    Thank you for your time and patient to help me with this one
    Last edited by NeMewSys; 05-22-2008 at 06:55 AM.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    > With this i think he creates the main window, I'm not sure becuz I cant find the word "mainWin" being used in other file except this main.cpp

    Look in the constructor for MainWindow.

    > 1st- I dont know if i should call with the name mainWin.newIdentity(), because it tells that mainWin is not declared, but it is declared from the main.cpp

    Where are you trying to call it from?
    Do you know how to use extern and headers in multi-file projects?
    Are you familiar with local variable and the concept of scope?
    Do you know what constructors and destructors are?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM