Chapitre 6. IBugtraqProvider interface

Table des matières

L'interface de IBugtraqProvider
L'interface de IBugtraqProvider2

To get a tighter integration with issue trackers than by simply using the bugtraq: properties, TortoiseSVN can make use of COM plugins. With such plugins it is possible to fetch information directly from the issue tracker, interact with the user and provide information back to TortoiseSVN about open issues, verify log messages entered by the user and even run actions after a successful commit to e.g, close an issue.

Nous ne pouvons pas vous indiquer comment développer un objet COM dans votre langage préféré, mais des exemples de greffons en C++/ATL et C# sont disponibles dans notre référentiel dans le répertoire contrib/issue-tracker-plugins. Vous pouvez également y trouver les fichiers à inlcure pour compiler votre greffon. (la section intitulée « TortoiseSVN est gratuit ! » explique comment accéder au référentiel).

L'interface de IBugtraqProvider

TortoiseSVN 1.5 peut être agrémenté de greffons qui ajouteront une interface pour IBugtraqProvider. Cette dernière fournira quelques méthodes que les greffons pourront utiliser pour s'interfacer avec le système de suivi d'anomalies logicielles.

HRESULT ValidateParameters (
  // Fenêtre parent pour toutes les interfaces devant être
  // affichées pendant la validation.
  [in] HWND hParentWnd,

  // La chaine en paramètre doit être validée.
  [in] BSTR parameters,

  // La chaine est elle valide ?
  [out, retval] VARIANT_BOOL *valid
);

Cette méthode est appele depuis la fenêtre des paramètres là où l'utilisateur peut ajouter et configurer le greffon. La chaine parametres peut être utilisée par un greffon pour avoir plus d'informations, i.e., les identifiants, l'URL du bug tracker, etc. Le greffon doit vérifier la chaine parametres et montrer une fenêtre d'erreur si la chaine n'est pas valide. Le paramètre hParentWnd permet au plugin d'accéder à la fenêtre mère. Le greffon DOIT renvoyer TRUE si la chaine parametres est validée. Si le greffon renvoie FALSE, la fenêtre de paramètrage n'autorisera pas l'utilisateur à ajouter le greffon au chemin d'une copie de travail.

HRESULT GetLinkText (
  // Fenêtre parent pour toutes les interfaces (d'erreur) devant être affiché.
  [in] HWND hParentWnd,

  // La chaine en paramètre, au cas où vous devriez communiquer avec votre
  // service web (i.e.) pour savoir qu'est ce qu'un texte correct.
  [in] BSTR parameters,

  // Quel texte voulez vous afficher ?
  // Utilisez le thread local courant.
  [out, retval] BSTR *linkText
);

Le greffon peut fournir une chaine ici laquelle sera utilisée dans la fenêtre de livraison de TortoiseSVN par le bouton qui appelle le greffon, i.e., "Choisir le bug" ou "Selectionner le ticket". Assurez vous que la chaine n'est pas trop longue, sinon elle ne rentrera pas dans le bouton. Si la méthode retourne une erreur (i.e., E_NOTIMPL), un texte par défaut est utilisé pour le bouton.

HRESULT GetCommitMessage (
  // Parent window for your provider's UI.
  [in] HWND hParentWnd,

  // Parameters for your provider.
  [in] BSTR parameters,
  [in] BSTR commonRoot,
  [in] SAFEARRAY(BSTR) pathList,

  // The text already present in the commit message.
  // Your provider should include this text in the new message,
  // where appropriate.
  [in] BSTR originalMessage,

  // The new text for the commit message.
  // This replaces the original message.
  [out, retval] BSTR *newMessage
);

This is the main method of the plugin. This method is called from the TortoiseSVN commit dialog when the user clicks on the plugin button. The parameters string is the string the user has to enter in the settings dialog when he configures the plugin. Usually a plugin would use this to find the URL of the issue tracker and/or login information or more. The commonRoot string contains the parent path of all items selected to bring up the commit dialog. Note that this is not the root path of all items which the user has selected in the commit dialog. The pathList parameter contains an array of paths (as strings) which the user has selected for the commit. The originalMessage parameter contains the text entered in the log message box in the commit dialog. If the user has not yet entered any text, this string will be empty. The newMessage return string is copied into the log message edit box in the commit dialog, replacing whatever is already there. If a plugin does not modify the originalMessage string, it must return the same string again here, otherwise any text the user has entered will be lost.