Quintasan / 7 years, 7 months ago | Download | Plaintext | Odpowiedz |

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
diff -Nru kdeplasma-addons-4.4.2/applets/microblog/microblog.cpp microblog/microblog.cpp
--- kdeplasma-addons-4.4.2/applets/microblog/microblog.cpp	2010-01-06 18:00:40.000000000 +0100
+++ microblog/microblog.cpp	2010-05-18 19:32:35.269129344 +0200
@@ -27,6 +27,8 @@
 #include <QGraphicsAnchorLayout>
 #include <QAction>
 #include <QTimer>
+#include <QFile>
+
 
 #include <KColorScheme>
 #include <KConfigDialog>
@@ -164,7 +166,7 @@
     m_serviceUrl = cg.readEntry("serviceUrl", "https://identi.ca/api/");
     m_username = cg.readEntry("username");
     m_password = KStringHandler::obscure(cg.readEntry("password"));
-    m_historySize = cg.readEntry("historySize", 6);
+    m_historySize = cg.readEntry("historySize", 10);
     m_historyRefresh = cg.readEntry("historyRefresh", 5);
     m_includeFriends = cg.readEntry("includeFriends", true);
 
@@ -261,6 +263,7 @@
     //set things in motion
     if (m_username.isEmpty()) {
         setAuthRequired(true);
+	downloadHistory();
     } else if (m_password.isEmpty()) {
         kDebug() << "started, password is not in config file, trying wallet";
         m_walletWait = Read;
@@ -351,7 +354,9 @@
     } else if (m_password.isEmpty()) {
         //FIXME: when out of string freeze, tell the user WHY they need
         //       to configure the widget;
-        setConfigurationRequired(true);
+        if (!QFile::exists("/usr/bin/ubiquity")) { //don't show on live CD
+	  setConfigurationRequired(true);
+	}
         kDebug() << "failed to read password";
     }
 
@@ -376,7 +381,9 @@
 
 void MicroBlog::setAuthRequired(bool required)
 {
-    setConfigurationRequired(required);
+    if (!QFile::exists("/usr/bin/ubiquity")) {
+      setConfigurationRequired(required);
+    }
     m_statusEdit->setEnabled(!required);
 }
 
@@ -758,12 +765,20 @@
 void MicroBlog::downloadHistory()
 {
     //kDebug() ;
-    if (m_username.isEmpty() || m_password.isEmpty()) {
+
+   if (m_username.isEmpty() || m_password.isEmpty()) {
+     /*
         if (!m_curTimeline.isEmpty()) {
             m_engine->disconnectSource(m_curTimeline, this);
             m_engine->disconnectSource("Error:" + m_curTimeline, this);
         }
         return;
+	*/
+
+	m_username = "kubuntu"; //default to show when unconfigured
+	m_headerFrame->hide();
+   } else {
+     m_headerFrame->show();
     }
 
     m_flash->flash(i18n("Refreshing timeline..."), -1);
@@ -774,7 +789,9 @@
     } else {
         createTimelineService();
         KConfigGroup cg = m_service->operationDescription("auth");
+	if (!m_password.isEmpty()) {
         cg.writeEntry("password", m_password);
+	}
         m_service->startOperationCall(cg);
     }
 
@@ -813,8 +830,10 @@
         query = "Replies:%1@%2";
         break;
     default:
-        if(m_includeFriends) {
-            query = QString("TimelineWithFriends:%1@%2");
+        if (m_password.isEmpty()) {
+            query = QString("NoAuth:%1@%2");
+	} else if (m_includeFriends) {
+	    query = QString("TimelineWithFriends:%1@%2");
         } else {
             query = QString("Timeline:%1@%2");
         }
 
diff -Nru kdeplasma-addons-4.4.2/dataengines/microblog/timelinesource.cpp microblog-dataengine/timelinesource.cpp
--- kdeplasma-addons-4.4.2/dataengines/microblog/timelinesource.cpp	2010-03-26 18:30:46.000000000 +0100
+++ microblog-dataengine/timelinesource.cpp	2010-05-18 19:35:25.779129363 +0200
@@ -97,6 +97,9 @@
     case TimelineWithFriends:
         m_url = KUrl(m_serviceBaseUrl, "statuses/friends_timeline.xml");
         break;
+    case NoAuth:
+	m_url = KUrl(m_serviceBaseUrl, QString("statuses/user_timeline/%1.xml").arg(account.at(0)));
+	break;
     case Timeline:
     default:
         m_url = KUrl(m_serviceBaseUrl, "statuses/user_timeline.xml");
@@ -141,7 +144,7 @@
 
 void TimelineSource::update(bool forcedUpdate)
 {
-    if (m_job || (!account().isEmpty() && password().isEmpty())) {
+    if ( account() != "kubuntu" && (m_job || (!account().isEmpty() && password().isEmpty())) ) {
         // We are already performing a fetch, let's not bother starting over
         //kDebug() << "already updating....." << m_job << account().isEmpty() << password().isEmpty();
         return;
diff -Nru kdeplasma-addons-4.4.2/dataengines/microblog/timelinesource.h microblog-dataengine/timelinesource.h
--- kdeplasma-addons-4.4.2/dataengines/microblog/timelinesource.h	2009-08-12 12:00:01.000000000 +0200
+++ microblog-dataengine/timelinesource.h	2010-05-18 19:35:52.568504430 +0200
@@ -80,7 +80,8 @@
         TimelineWithFriends,
         Replies,
         DirectMessages,
-        Profile
+        Profile,
+	NoAuth
     };
 
     TimelineSource(const QString &who, RequestType requestType, QObject* parent);
diff -Nru kdeplasma-addons-4.4.2/dataengines/microblog/twitterengine.cpp microblog-dataengine/twitterengine.cpp
--- kdeplasma-addons-4.4.2/dataengines/microblog/twitterengine.cpp	2009-08-12 12:00:01.000000000 +0200
+++ microblog-dataengine/twitterengine.cpp	2010-05-18 19:39:07.598424935 +0200
@@ -30,6 +30,7 @@
 const QString TwitterEngine::timelinePrefix("Timeline:");
 const QString TwitterEngine::timelineWithFriendsPrefix("TimelineWithFriends:");
 const QString TwitterEngine::profilePrefix("Profile:");
+const QString TwitterEngine::noauthPrefix("NoAuth:");
 const QString TwitterEngine::repliesPrefix("Replies:");
 const QString TwitterEngine::messagesPrefix("Messages:");
 
@@ -53,7 +54,7 @@
 
     if (!name.startsWith(timelinePrefix) && !name.startsWith(timelineWithFriendsPrefix)
         && !name.startsWith(profilePrefix) && !name.startsWith(repliesPrefix)
-        && !name.startsWith(messagesPrefix)) {
+        && !name.startsWith(messagesPrefix) && !name.startsWith(noauthPrefix)) {
         return false;
     }
 
@@ -81,11 +82,10 @@
 //always returns false because everything is async
 bool TwitterEngine::updateSourceEvent(const QString &name)
 {
-    //kDebug() << name;
     //right now it only makes sense to do an update on timelines
     if (!name.startsWith(timelinePrefix) && !name.startsWith(timelineWithFriendsPrefix)
         && !name.startsWith(profilePrefix) && !name.startsWith(repliesPrefix)
-        && !name.startsWith(messagesPrefix)) {
+        && !name.startsWith(messagesPrefix) && !name.startsWith(noauthPrefix)) {
         return false;
     }
 
@@ -98,6 +98,9 @@
     } else if (name.startsWith(profilePrefix)) {
         requestType = TimelineSource::Profile;
         who.remove(profilePrefix);
+    } else if (name.startsWith(noauthPrefix)) {
+      requestType = TimelineSource::NoAuth;
+      who.remove(noauthPrefix);
     } else if (name.startsWith(repliesPrefix)) {
         requestType = TimelineSource::Replies;
         who.remove(repliesPrefix);
diff -Nru kdeplasma-addons-4.4.2/dataengines/microblog/twitterengine.h microblog-dataengine/twitterengine.h
--- kdeplasma-addons-4.4.2/dataengines/microblog/twitterengine.h	2009-08-12 12:00:01.000000000 +0200
+++ microblog-dataengine/twitterengine.h	2010-05-18 19:39:32.719129811 +0200
@@ -67,6 +67,7 @@
         static const QString timelinePrefix;
         static const QString timelineWithFriendsPrefix;
         static const QString profilePrefix;
+	static const QString noauthPrefix;
         static const QString repliesPrefix;
         static const QString messagesPrefix;
         ImageSource *m_imageSource;