Jump to content


How to write a custom C++ plugin

plugin c++

  • Please log in to reply
4 replies to this topic

#1 MPeli

MPeli

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 02 February 2017 - 11:07 AM

Hi,

  I have written my own software for Mac and Win which works with files on local disk. The files were cloned from a perforce repository. I would like my software to be able to checkout and revert some of the files. Therefore, I would like to write a custom plugin. It would be very similar to Visual Studio plugin. Is there some open source code which I could use? Visual Studio plugin does not ask for password when creating a connection. Is it possible for a custom plugin not to ask for password as well?

Thank you, Martin.

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 976 posts

Posted 02 February 2017 - 07:01 PM

These are the two docs you'll need:

https://www.perforce...dref/index.html
https://www.perforce...4api/index.html

The Command Reference tells you how the p4 server commands work; the C++ API guide tells you how to connect to the server and run those commands using C++ classes.  My advice to people asking how to write a Perforce app is always to start by getting familiar with the command line; once you know how to run p4 commands to accomplish what you're trying to do it's very easy to write an app that'll do the same thing since you're using the exact same server endpoints.

#3 MPeli

MPeli

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 03 February 2017 - 10:20 AM

Thank you very much. The Command Reference is understandable. I managed to login, list workspaces, checkout a file, revert it... and log out. If I list tickets (p4 tickets), I see that there is an existing ticket with my user name. I assume that p4v client created it. Could I reuse the ticket?

I would like to know how it is possible that visual studio plugin does not ask for password. Thank you.

#4 MPeli

MPeli

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 03 February 2017 - 01:50 PM

I had troubles calling following command

p4 -u my_user -c my_workspace -p server:port revert README.md

Once I specified dir, everything was ok. It reused automatically existing connection and I did not have to login nor enter a password.

p4 -u my_user -c my_workspace -p -d /Users/my_user/perforce/branch server:port revert README.md


#5 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 976 posts

Posted 03 February 2017 - 10:31 PM

The command line client reads your current directory from your shell's $PWD, so if that's at odds with your actual current directory, that'll cause problems.  The current directory is used to interpret relative paths (like "README.md"), and it's also used to load your P4CONFIG file, if any, so if you have your P4PORT/etc set in P4CONFIG in a particular directory, running commands from outside that directory won't pick up your P4PORT setting.

Tickets are stored in a single shared file that's specified by either P4TICKETS or defaults to ~/.p4tickets.  If you've already logged in and have a valid ticket, any Perforce client app should be able to authenticate using that ticket.  If the ticket is absent or has expired, no server command will work until you run "p4 login" and get a new one.





Also tagged with one or more of these keywords: plugin, c++

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users