Make Twitter/Identi.ca selection a compile time option
handled via one constant variable.
3 files changed, 80 insertions(+), 9 deletions(-)

M src/twitter.adb
A => src/urls.adb
A => src/urls.ads
M src/twitter.adb +12 -9
@@ 4,8 4,13 @@ with OAuth;
 with OAuth.Easy;
 with Properties;
 with HTTP;
+with URLs;
 
 package body Twitter is
+   use URLs;
+
+   Microblog : constant Microblog_Type := TWITTER_BLOG; -- IDENTICA_BLOG;
+
    procedure Init (Manager : out Twitter_Type) is
    begin
       Manager.My_Token := To_Unbounded_String (Secrets.Get_Token);

          
@@ 38,10 43,10 @@ package body Twitter is
          Consumer_Secret => Secrets.Get_Consumer_Secret);
       OAuth.Easy.Request_Token
         (Context => Manager.C,
-         URL     => "https://identi.ca/api/oauth/request_token",
+         URL     => Request_Token_URL (Microblog),
          Method  => "GET");
       URL := To_Unbounded_String
-        ("https://identi.ca/api/oauth/authorize?oauth_token="
+        (OAuth_Token_URL (Microblog) & "?oauth_token="
          & To_String (OAuth.Easy.Get_Token (Manager.C)));
    end Auth_Get_PIN_URL;
 

          
@@ 52,7 57,7 @@ package body Twitter is
    begin
       OAuth.Easy.Access_Token
         (Context  => Manager.C,
-         URL      => "https://identi.ca/api/oauth/access_token",
+         URL      => Access_Token_URL (Microblog),
          Method   => "GET",
          Verifier => PIN,
          User_Id  => User_Id,

          
@@ 66,8 71,7 @@ package body Twitter is
                        Tweets  : out Charbuf.Char_Buffer) is
       use OAuth;
 
-      Home_URL : constant String :=
-        "http://identi.ca/api/statuses/home_timeline.json";
+      Home_URL : constant String := Home_Timeline_URL (Microblog);
       OAuth_Header : Unbounded_String;
       Extra_Params : Parameter_List.List := Parameter_List.Empty_List;
       Result : Charbuf.Char_Buffer;

          
@@ 95,8 99,7 @@ package body Twitter is
                      Message :        String) is
       use OAuth;
 
-      Update_URL : constant String :=
-        "http://identi.ca/api/statuses/update.json";
+      Update_Address : constant String := Update_URL (Microblog);
       OAuth_Header : Unbounded_String;
       Extra_Params : Parameter_List.List := Parameter_List.Empty_List;
       Result : Charbuf.Char_Buffer;

          
@@ 106,10 109,10 @@ package body Twitter is
         (To_Unbounded_String ("status"),
           To_Unbounded_String (Message)));
       Easy.As_Header
-        (Manager.C, Update_URL, "POST", Extra_Params, OAuth_Header);
+        (Manager.C, Update_Address, "POST", Extra_Params, OAuth_Header);
       Put_Line ("Header: " & To_String (OAuth_Header));
       HTTP.Post_Page
-        (URL => Update_URL,
+        (URL => Update_Address,
          Header_Key => "Authorization",
          Header_Value => To_String (OAuth_Header),
          Fields => "status=" & Message,

          
A => src/urls.adb +53 -0
@@ 0,0 1,53 @@ 
+
+package body URLs is
+   function Request_Token_URL (Blog : Microblog_Type) return String is
+   begin
+      case Blog is
+         when TWITTER_BLOG =>
+            return "https://api.twitter.com/oauth/request_token";
+         when IDENTICA_BLOG =>
+            return "https://identi.ca/api/oauth/request_token";
+      end case;
+   end Request_Token_URL;
+
+   function OAuth_Token_URL (Blog : Microblog_Type) return String is
+   begin
+      case Blog is
+         when TWITTER_BLOG =>
+            return "https://api.twitter.com/oauth/authorize";
+         when IDENTICA_BLOG =>
+            return "https://identi.ca/api/oauth/authorize";
+      end case;
+   end OAuth_Token_URL;
+
+   function Access_Token_URL (Blog : Microblog_Type) return String is
+   begin
+      case Blog is
+         when TWITTER_BLOG =>
+            return "https://api.twitter.com/oauth/access_token";
+         when IDENTICA_BLOG =>
+            return "https://identi.ca/api/oauth/access_token";
+      end case;
+   end Access_Token_URL;
+
+   function Home_Timeline_URL (Blog : Microblog_Type) return String is
+   begin
+      case Blog is
+         when TWITTER_BLOG =>
+            return "http://api.twitter.com/1/statuses/home_timeline.json";
+         when IDENTICA_BLOG =>
+            return "http://identi.ca/api/statuses/home_timeline.json";
+      end case;
+   end Home_Timeline_URL;
+
+   function Update_URL (Blog : Microblog_Type) return String is
+   begin
+      case Blog is
+         when TWITTER_BLOG =>
+            return "http://api.twitter.com/1/statuses/update.json";
+         when IDENTICA_BLOG =>
+            return "http://identi.ca/api/statuses/update.json";
+      end case;
+   end Update_URL;
+
+end URLs;

          
A => src/urls.ads +15 -0
@@ 0,0 1,15 @@ 
+
+package URLs is
+   type Microblog_Type is (TWITTER_BLOG, IDENTICA_BLOG);
+
+   function Request_Token_URL (Blog : Microblog_Type) return String;
+
+   function OAuth_Token_URL (Blog : Microblog_Type) return String;
+
+   function Access_Token_URL (Blog : Microblog_Type) return String;
+
+   function Home_Timeline_URL (Blog : Microblog_Type) return String;
+
+   function Update_URL (Blog : Microblog_Type) return String;
+
+end URLs;