Beispiel #1
0
        /**
         * Creates <em>most</em> everything needed for a tutorial session; the Account instance is populated during sign-in.
         *
         * @param tutorialTag
         *  The tutorial's class name. If null or the empty string, default it to <code>T_TAG_DFLT</code>.
         * @param accountName
         *  The <em>name</em> of the account to use for this tutorial. If null or the empty string,
         *  <em>fail</em> by throwing a RuntimeException indicating that fact.
         * @param pathName
         *  Pathname of the certificate file, which should be a PEM file.
         *
         * @return
         * <ul>
         *   <li>true: session initialized</li>
         *   <li>false: session initialization failed due to:
         *      <ul>
         *          <li>no or empty account name</li>
         *          <li>com.skype.api.Skype.Init failed - most likely from an invalid AppKeyPair</li>
         *          <li>could not obtain an Account instance</li>
         *      </ul>
         *   </li>
         * </ul>
         *
         * @see com.skype.tutorial.util.SignInMgr
         *
         * @since 1.0
         */
        /*	public boolean doCreateSession(String tutorialTag, String accountName, AppKeyPairMgr myAppKeyPairMgr) {
         */
        public bool doCreateSession(String tutorialTag, String accountName, String pathName)
        {
            if ((tutorialTag != null) && (tutorialTag.Length != 0))
            {
                myTutorialTag = tutorialTag;
            }
            else
            {
                myTutorialTag = T_TAG_DFLT;
            }

            if ((accountName != null) && (accountName.Length != 0))
            {
                myAccountName = accountName; // All tutorials minimally require an account name
            }
            else
            {
                throw new Exception((myTutorialTag + ": Cannot initialize session instance - no account name!"));
            }

            // Set up our session with the SkypeKit runtime...
            // Note that most of the Skype methods - including static methods and GetVersionString - will
            // fail and/or throw an exception if invoked prior to successful initialization!
            mySkype = new Skype();
            myClientConfiguration = new ClientConfiguration();
            myClientConfiguration.setTcpTransport(IP_ADDR, PORT_NUM);
            myClientConfiguration.setCertificate(pathName);
            myListeners = new Listeners(this);
            myConsole.printf("%s: Instantiated Skype, ClientConfiguration, and Listeners instances...%n", myTutorialTag);

            mySkype.init(myClientConfiguration, myListeners);
            mySkype.start(); // You must invoke start --immediately-- after invoking init!

            myParseSkypeKitVersion = new ParseSkypeKitVersion(mySkype);
            myConsole.printf("%s: Initialized MySkype instance - version = %s (%d.%d.%d)%n",
                             myTutorialTag, myParseSkypeKitVersion.getVersionStr(),
                             myParseSkypeKitVersion.getMajorVersion(),
                             myParseSkypeKitVersion.getMinorVersion(),
                             myParseSkypeKitVersion.getPatchVersion());


            // Get the Account
            if ((myAccount = mySkype.getAccount(myAccountName)) == null)
            {
                myConsole.printf("%s: Could not get Account for %s!%n", myTutorialTag, myAccountName);
                myConsole.printf("%s: Session initialization failed!%n", myTutorialTag);
                return(false);
            }

            myConsole.printf("%s: Got Account for %s%n", myTutorialTag, myAccountName);
            myConsole.printf("%s: Initialized session!%n", myTutorialTag);

            return(true);
        }
Beispiel #2
0
        /**
         * Creates <em>most</em> everything needed for a tutorial session; the Account instance is populated during sign-in.
         *
         * @param tutorialTag
         *  The tutorial's class name. If null or the empty string, default it to <code>T_TAG_DFLT</code>.
         * @param accountName
         *  The <em>name</em> of the account to use for this tutorial. If null or the empty string,
         *  <em>fail</em> by throwing a RuntimeException indicating that fact.
         * @param pathName
         * 	Pathname of the certificate file, which should be a PEM file.
         *
         * @return
         * <ul>
         *   <li>true: session initialized</li>
         *   <li>false: session initialization failed due to:
         *   	<ul>
         *   		<li>no or empty account name</li>
         *   		<li>com.skype.api.Skype.Init failed - most likely from an invalid AppKeyPair</li>
         *   		<li>could not obtain an Account instance</li>
         *   	</ul>
         *   </li>
         * </ul>
         *
         * @see com.skype.tutorial.util.SignInMgr
         *
         * @since 1.0
         */
        /*	public boolean doCreateSession(String tutorialTag, String accountName, AppKeyPairMgr myAppKeyPairMgr) {
        */
        public bool doCreateSession(String tutorialTag, String accountName, String pathName)
        {
            if ((tutorialTag != null) && (tutorialTag.Length != 0))
            {
                myTutorialTag = tutorialTag;
            }
            else
            {
                myTutorialTag = T_TAG_DFLT;
            }

            if ((accountName != null) && (accountName.Length != 0))
            {
                myAccountName = accountName; // All tutorials minimally require an account name
            }
            else
            {
                throw new Exception((myTutorialTag + ": Cannot initialize session instance - no account name!"));
            }

            // Set up our session with the SkypeKit runtime...
            // Note that most of the Skype methods - including static methods and GetVersionString - will
            // fail and/or throw an exception if invoked prior to successful initialization!
            mySkype = new Skype();
            myClientConfiguration = new ClientConfiguration();
            myClientConfiguration.setTcpTransport(IP_ADDR, PORT_NUM);
            myClientConfiguration.setCertificate(pathName);
            myListeners = new Listeners(this);
            myConsole.printf("%s: Instantiated Skype, ClientConfiguration, and Listeners instances...%n", myTutorialTag);

            mySkype.init(myClientConfiguration, myListeners);
            mySkype.start(); // You must invoke start --immediately-- after invoking init!

            myParseSkypeKitVersion = new ParseSkypeKitVersion(mySkype);
            myConsole.printf("%s: Initialized MySkype instance - version = %s (%d.%d.%d)%n",
                        myTutorialTag, myParseSkypeKitVersion.getVersionStr(),
                        myParseSkypeKitVersion.getMajorVersion(),
                        myParseSkypeKitVersion.getMinorVersion(),
                        myParseSkypeKitVersion.getPatchVersion());

            // Get the Account
            if ((myAccount = mySkype.getAccount(myAccountName)) == null)
            {
                myConsole.printf("%s: Could not get Account for %s!%n", myTutorialTag, myAccountName);
                myConsole.printf("%s: Session initialization failed!%n", myTutorialTag);
                return (false);
            }

            myConsole.printf("%s: Got Account for %s%n", myTutorialTag, myAccountName);
            myConsole.printf("%s: Initialized session!%n", myTutorialTag);

            return (true);
        }