[tuxdroid-svn] r5707 - software_suite_v3/software/plugin/plugin-facebook/branches/october_release/s
Status: Beta
Brought to you by:
ks156
|
From: jerome <c2m...@c2...> - 2009-10-16 09:04:52
|
Author: jerome Date: 2009-10-16 11:04:39 +0200 (Fri, 16 Oct 2009) New Revision: 5707 Modified: software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookConnection.java software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookFunctions.java software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookPlugin.java Log: * Removed old connection job. Modified: software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookConnection.java =================================================================== --- software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookConnection.java 2009-10-16 08:44:43 UTC (rev 5706) +++ software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookConnection.java 2009-10-16 09:04:39 UTC (rev 5707) @@ -20,90 +20,27 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -import java.io.File; -import java.io.IOException; +import com.google.code.facebookapi.FacebookJsonRestClient; -import com.facebook.api.FacebookException; -import com.facebook.api.FacebookRestClient; - public class FacebookConnection { public static String api_key = "a9eb7b7e52df160fb1dfc437b0b487c8"; public static String f_key = "0314c8569f89d0411e5a4823372ae27a"; - private FacebookRestClient client; - private Long userId; - private boolean state = true; + private FacebookJsonRestClient client; + /** * Class constructor. */ - public FacebookConnection(FacebookPlugin plugin, String login, String password) + public FacebookConnection() { - try - { - //Create the client instance - client = new FacebookRestClient(FacebookConnection.api_key, FacebookConnection.f_key); - - //Is this a desktop app - client.setIsDesktop(true); - - //Getting an auth-token to log in with - String token = client.auth_createToken(); - - // Build the authentication URL for the user to fill out - String url = "http://www.facebook.com/login.php?api_key=" + FacebookConnection.api_key + "&v=1.0" + "&auth_token=" + token; - - - File app = new File("./resources/Facebook_connection.exe"); - - if(app.exists()) - { - - String[] cmd = new String[]{app.getAbsolutePath(), url, login, password}; - - Process log = Runtime.getRuntime().exec(cmd); - try - { - log.waitFor(); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - } - - // fetch session key - String session = client.auth_getSession(token); - - if(session == null) - { - plugin.throwMessage("I cannot get connected to your facebook account."); - state = false; - } - - // keep track of the logged in user id - userId = client.users_getLoggedInUser(); - } - catch(FacebookException connectionError) - { - plugin.throwMessage("I cannot get connected to your facebook account."); - state = false; - } - catch (IOException e) - { - e.printStackTrace(); - state = false; - } + //TODO facebook connection. } - /** - * Return the connection state. - * @return - */ - public synchronized boolean getState() + public boolean Connect(String username, String password) { - return this.state; + return true; } @@ -113,16 +50,18 @@ */ public Long getFacebookUserId() { - return this.userId; + //TODO + return null; } /** - * Return the JSon object. + * Return the JSon Facebook client object. * @return */ - public FacebookRestClient getClient() + public FacebookJsonRestClient getClient() { - return this.client; + //TODO + return null; } } Modified: software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookFunctions.java =================================================================== --- software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookFunctions.java 2009-10-16 08:44:43 UTC (rev 5706) +++ software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookFunctions.java 2009-10-16 09:04:39 UTC (rev 5707) @@ -21,19 +21,16 @@ */ -import java.io.IOException; import java.util.EnumSet; import java.util.Hashtable; import java.util.List; import java.util.Vector; -import com.facebook.api.FacebookException; -import com.facebook.api.ProfileField; -import com.facebook.api.schema.Event; -import com.facebook.api.schema.EventsGetResponse; -import com.facebook.api.schema.FriendsGetResponse; -import com.facebook.api.schema.User; -import com.facebook.api.schema.UsersGetInfoResponse; +import com.google.code.facebookapi.FacebookException; +import com.google.code.facebookapi.ProfileField; +import com.google.code.facebookapi.schema.FriendsGetResponse; +import com.google.code.facebookapi.schema.User; +import com.google.code.facebookapi.schema.UsersGetInfoResponse; public class FacebookFunctions { @@ -83,10 +80,6 @@ { return null; } - catch (IOException e) - { - return null; - } return friendsList; } @@ -383,10 +376,6 @@ { ; } - catch (IOException e) - { - ; - } return notifications; } Modified: software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookPlugin.java =================================================================== --- software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookPlugin.java 2009-10-16 08:44:43 UTC (rev 5706) +++ software_suite_v3/software/plugin/plugin-facebook/branches/october_release/src/FacebookPlugin.java 2009-10-16 09:04:39 UTC (rev 5707) @@ -205,161 +205,168 @@ if(true) { - FacebookConnection facebook = new FacebookConnection(this, this.configuration().getLogin(), this.configuration().getPassword()); - FacebookFunctions functions = new FacebookFunctions(facebook); - - //Get email informations. - if(this.configuration().notifyEmail) + FacebookConnection facebook = new FacebookConnection(); + if ( facebook.Connect(this.configuration().getLogin(), this.configuration().getPassword()) ) { - if(functions.getEmailNotifications().intValue() > 0) + FacebookFunctions functions = new FacebookFunctions(facebook); + + //Get email informations. + if(this.configuration().notifyEmail) { - news = true; - if(this.check && (!throwNotif)) + if(functions.getEmailNotifications().intValue() > 0) { - throwNotif = true; - this.throwResult(true); + news = true; + if(this.check && (!throwNotif)) + { + throwNotif = true; + this.throwResult(true); + } + + if(functions.getEmailNotifications().intValue() == 1) + { + throwMessage("You have one new message"); + } + else + { + throwMessage("You have {0} new messages", functions.getEmailNotifications().intValue()); + } } - - if(functions.getEmailNotifications().intValue() == 1) - { - throwMessage("You have one new message"); - } - else - { - throwMessage("You have {0} new messages", functions.getEmailNotifications().intValue()); - } } - } - - //Get friend requests notification. - if(this.configuration().showFriendRequests) - { - if(functions.getFriendRequestsCount().intValue() > 0) + + //Get friend requests notification. + if(this.configuration().showFriendRequests) { - news = true; - if(this.check && (!throwNotif)) + if(functions.getFriendRequestsCount().intValue() > 0) { - throwNotif = true; - this.throwResult(true); - } - - if(functions.getFriendRequestsCount().intValue() == 1) - { - throwMessage("You have one friend request"); - } - else - { - throwMessage("You have {0} friend requests", functions.getFriendRequestsCount()); - } - - for(String friendName : functions.getFriendRequestNames()) - { + news = true; if(this.check && (!throwNotif)) { throwNotif = true; this.throwResult(true); } - throwMessage("From {0}", friendName); + + if(functions.getFriendRequestsCount().intValue() == 1) + { + throwMessage("You have one friend request"); + } + else + { + throwMessage("You have {0} friend requests", functions.getFriendRequestsCount()); + } + + for(String friendName : functions.getFriendRequestNames()) + { + if(this.check && (!throwNotif)) + { + throwNotif = true; + this.throwResult(true); + } + throwMessage("From {0}", friendName); + } } } - } - - //Get group invites notifications. - if(this.configuration().showGroupsInvites) - { - news = true; - if(functions.getGroupsInvitesCount().intValue() > 0) + + //Get group invites notifications. + if(this.configuration().showGroupsInvites) { - if(this.check && (!throwNotif)) + news = true; + if(functions.getGroupsInvitesCount().intValue() > 0) { - throwNotif = true; - this.throwResult(true); - } - - if(functions.getGroupsInvitesCount().intValue() == 1) - { - throwMessage("You have one group invite"); - } - else - { - throwMessage("You have {0} group invites", functions.getGroupsInvitesCount().intValue()); - } - - for(String group : functions.getGroupInvitesNames()) - { if(this.check && (!throwNotif)) { throwNotif = true; this.throwResult(true); } - throwMessage("to {0}", group); + + if(functions.getGroupsInvitesCount().intValue() == 1) + { + throwMessage("You have one group invite"); + } + else + { + throwMessage("You have {0} group invites", functions.getGroupsInvitesCount().intValue()); + } + + for(String group : functions.getGroupInvitesNames()) + { + if(this.check && (!throwNotif)) + { + throwNotif = true; + this.throwResult(true); + } + throwMessage("to {0}", group); + } } } - } - - //Get pokes notification. - if(this.configuration().showEventsInvites) - { - if(functions.getEventsInvitesCount().intValue() > 0) + + //Get pokes notification. + if(this.configuration().showEventsInvites) { - news = true; - if(this.check && (!throwNotif)) + if(functions.getEventsInvitesCount().intValue() > 0) { - throwNotif = true; - this.throwResult(true); - } - - if(functions.getEventsInvitesCount().intValue() == 1) - { - throwMessage("You have one event invite"); - } - else - { - throwMessage("You have {0} event invites", functions.getEventsInvitesCount().intValue()); - } - - for(String event : functions.getEventInvitesNames()) - { + news = true; if(this.check && (!throwNotif)) { throwNotif = true; this.throwResult(true); } - throwMessage("to {0}", event); + + if(functions.getEventsInvitesCount().intValue() == 1) + { + throwMessage("You have one event invite"); + } + else + { + throwMessage("You have {0} event invites", functions.getEventsInvitesCount().intValue()); + } + + for(String event : functions.getEventInvitesNames()) + { + if(this.check && (!throwNotif)) + { + throwNotif = true; + this.throwResult(true); + } + throwMessage("to {0}", event); + } } } - } - - if(this.configuration().showPokes) - { - if(functions.getPokesCount().intValue() > 0) + + if(this.configuration().showPokes) { - news = true; - if(this.check && (!throwNotif)) + if(functions.getPokesCount().intValue() > 0) { - throwNotif = true; - this.throwResult(true); + news = true; + if(this.check && (!throwNotif)) + { + throwNotif = true; + this.throwResult(true); + } + + if(functions.getPokesCount().intValue() == 1) + { + throwMessage("You have one poke"); + } + else + { + throwMessage("You have {0} pokes", functions.getPokesCount().intValue()); + } } - - if(functions.getPokesCount().intValue() == 1) - { - throwMessage("You have one poke"); - } - else - { - throwMessage("You have {0} pokes", functions.getPokesCount().intValue()); - } } + + if((!throwNotif) && this.check ) + { + this.throwResult(false); + } + else if((!this.check) && (!news)) + { + this.throwMessage("Nothing new on your account"); + } } - - if((!throwNotif) && this.check ) + else { - this.throwResult(false); + this.throwMessage("I cannot get connected to your facebook account."); } - else if((!this.check) && (!news) && (facebook.getState())) - { - this.throwMessage("Nothing new on your account"); - } } else { |