Skip to content

Commit

Permalink
Preparation to move dev branch to github
Browse files Browse the repository at this point in the history
yep, it's finally here
  • Loading branch information
DrKLO committed Mar 22, 2014
1 parent 4ede311 commit 5141fc1
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 111 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.idea/
.gradle/
build/
obj/
*.iml
local.properties
local.properties
*.keystore
gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package jawnae.pyronet;

import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;

import java.io.IOException;
Expand All @@ -30,14 +30,14 @@ public void connectedClient(PyroClient client) {
}

public void unconnectableClient(PyroClient client, Exception cause) {
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "unconnectable");
}
}

public void droppedClient(PyroClient client, IOException cause) {
if (cause != null) {
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", this.getClass().getSimpleName() + ".droppedClient() caught exception: " + cause);
}
}
Expand Down
18 changes: 18 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* This is the source code of Telegram for Android v. 1.3.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/

package org.telegram.messenger;

public class BuildVars {
public static boolean DEBUG_VERSION = true;
public static int APP_ID = 2458;
public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217";
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";
public static String GCM_SENDER_ID = "760348033672";
public static String SEND_LOGS_EMAIL = "email@gmail.com";
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@
import java.util.regex.Pattern;

public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.TcpConnectionDelegate {
public static boolean DEBUG_VERSION = true;
public static int APP_ID = 2458;
public static String APP_HASH = "5bce48dc7d331e62c955669eb7233217";
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";
public static String GCM_SENDER_ID = "760348033672";
public static String SEND_LOGS_EMAIL = "email@gmail.com";

private HashMap<Integer, Datacenter> datacenters = new HashMap<Integer, Datacenter>();
private HashMap<Long, ArrayList<Long>> processedMessageIdsSet = new HashMap<Long, ArrayList<Long>>();
private HashMap<Long, Integer> nextSeqNoInSession = new HashMap<Long, Integer>();
Expand Down Expand Up @@ -728,7 +721,7 @@ TLObject wrapInLayer(TLObject object, int datacenterId, RPCRequest request) {
request.initRequest = true;
TLRPC.initConnection invoke = new TLRPC.initConnection();
invoke.query = object;
invoke.api_id = APP_ID;
invoke.api_id = BuildVars.APP_ID;
try {
invoke.lang_code = Locale.getDefault().getCountry();
invoke.device_model = Build.MANUFACTURER + Build.MODEL;
Expand Down Expand Up @@ -1637,7 +1630,7 @@ byte[] createConnectionData(ArrayList<NetworkMessage> messages, long sessionId,
NetworkMessage networkMessage = messages.get(0);
TLRPC.TL_protoMessage message = networkMessage.protoMessage;

if (DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
if (message.body instanceof TLRPC.invokeWithLayer12) {
FileLog.d("tmessages", sessionId + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer12)message.body).query);
} else if (message.body instanceof TLRPC.initConnection) {
Expand Down Expand Up @@ -1677,7 +1670,7 @@ byte[] createConnectionData(ArrayList<NetworkMessage> messages, long sessionId,
for (NetworkMessage networkMessage : messages) {
TLRPC.TL_protoMessage message = networkMessage.protoMessage;
containerMessages.add(message);
if (DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
if (message.body instanceof TLRPC.invokeWithLayer12) {
FileLog.d("tmessages", sessionId + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer12)message.body).query);
} else if (message.body instanceof TLRPC.initConnection) {
Expand Down Expand Up @@ -2445,7 +2438,7 @@ public void tcpConnectionClosed(TcpConnection connection) {
} else {
connectionState = 1;
}
if (DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
try {
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] networkInfos = cm.getAllNetworkInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public void run() {
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "need delete contacts");
for (HashMap.Entry<Integer, Contact> c : contactHashMap.entrySet()) {
Contact contact = c.getValue();
Expand Down Expand Up @@ -590,7 +590,7 @@ public void run() {

if (request) {
if (!toImport.isEmpty()) {
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "start import contacts");
for (TLRPC.TL_inputPhoneContact contact : toImport) {
FileLog.e("tmessages", "add contact " + contact.first_name + " " + contact.last_name + " " + contact.phone);
Expand All @@ -613,7 +613,7 @@ public void run(TLObject response, TLRPC.TL_error error) {
MessagesStorage.getInstance().putCachedPhoneBook(contactsMap);
}
TLRPC.TL_contacts_importedContacts res = (TLRPC.TL_contacts_importedContacts)response;
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
for (TLRPC.User user : res.users) {
FileLog.e("tmessages", "received user " + user.first_name + " " + user.last_name + " " + user.phone);
}
Expand Down Expand Up @@ -776,7 +776,7 @@ public void run() {
if (user != null) {
usersDict.put(user.id, user);

if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "loaded user contact " + user.first_name + " " + user.last_name + " " + user.phone);
}
}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ public void addContact(TLRPC.User user) {
contactsParams.add(c);
req.contacts = contactsParams;
req.replace = false;
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "add contact " + user.first_name + " " + user.last_name + " " + user.phone);
}
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
Expand All @@ -1410,7 +1410,7 @@ public void run(TLObject response, TLRPC.TL_error error) {
final TLRPC.TL_contacts_importedContacts res = (TLRPC.TL_contacts_importedContacts)response;
MessagesStorage.getInstance().putUsersAndChats(res.users, null, true, true);

if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
for (TLRPC.User user : res.users) {
FileLog.e("tmessages", "received user " + user.first_name + " " + user.last_name + " " + user.phone);
}
Expand Down
10 changes: 5 additions & 5 deletions TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static FileLog getInstance() {
}

public FileLog() {
if (!ConnectionsManager.DEBUG_VERSION) {
if (!BuildVars.DEBUG_VERSION) {
return;
}
dateFormat = FastDateFormat.getInstance("dd_MM_yyyy_HH_mm_ss", Locale.US);
Expand Down Expand Up @@ -70,7 +70,7 @@ public FileLog() {
}

public static void e(final String tag, final String message, final Throwable exception) {
if (!ConnectionsManager.DEBUG_VERSION) {
if (!BuildVars.DEBUG_VERSION) {
return;
}
Log.e(tag, message, exception);
Expand All @@ -91,7 +91,7 @@ public void run() {
}

public static void e(final String tag, final String message) {
if (!ConnectionsManager.DEBUG_VERSION) {
if (!BuildVars.DEBUG_VERSION) {
return;
}
Log.e(tag, message);
Expand All @@ -111,7 +111,7 @@ public void run() {
}

public static void e(final String tag, final Exception e) {
if (!ConnectionsManager.DEBUG_VERSION) {
if (!BuildVars.DEBUG_VERSION) {
return;
}
e.printStackTrace();
Expand All @@ -137,7 +137,7 @@ public void run() {
}

public static void d(final String tag, final String message) {
if (!ConnectionsManager.DEBUG_VERSION) {
if (!BuildVars.DEBUG_VERSION) {
return;
}
Log.d(tag, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;

import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.MessagesController;
Expand Down Expand Up @@ -228,7 +229,7 @@ protected Boolean doInBackground(String... objects) {
while (count < 1000) {
try {
count++;
regid = gcm.register(ConnectionsManager.GCM_SENDER_ID);
regid = gcm.register(BuildVars.GCM_SENDER_ID);
sendRegistrationIdToBackend(true);
storeRegistrationId(applicationContext, regid);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import android.widget.Toast;

import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.MessagesController;
Expand Down Expand Up @@ -526,12 +527,12 @@ public void didSelectDialog(MessagesActivity messageFragment, long dialog_id) {
}

private void checkForCrashes() {
CrashManager.register(this, ConnectionsManager.HOCKEY_APP_HASH);
CrashManager.register(this, BuildVars.HOCKEY_APP_HASH);
}

private void checkForUpdates() {
if (ConnectionsManager.DEBUG_VERSION) {
UpdateManager.register(this, ConnectionsManager.HOCKEY_APP_HASH);
if (BuildVars.DEBUG_VERSION) {
UpdateManager.register(this, BuildVars.HOCKEY_APP_HASH);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.widget.TextView;

import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
Expand Down Expand Up @@ -328,8 +329,8 @@ public void onNextPressed() {
TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode();
String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText());
ConnectionsManager.getInstance().applyCountryPortNumber(phone);
req.api_hash = ConnectionsManager.APP_HASH;
req.api_id = ConnectionsManager.APP_ID;
req.api_hash = BuildVars.APP_HASH;
req.api_id = BuildVars.APP_ID;
req.sms_type = 0;
req.phone_number = phone;
req.lang_code = Locale.getDefault().getCountry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.widget.Toast;

import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.SerializedData;
import org.telegram.messenger.TLClassStore;
Expand Down Expand Up @@ -169,7 +170,7 @@ public void run() {
textSizeRow = rowCount++;
sendByEnterRow = rowCount++;
supportSectionRow = rowCount++;
if (ConnectionsManager.DEBUG_VERSION) {
if (BuildVars.DEBUG_VERSION) {
sendLogsRow = rowCount++;
clearLogsRow = rowCount++;
}
Expand Down Expand Up @@ -484,7 +485,7 @@ private void sendLogs() {
}
Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
i.setType("message/rfc822") ;
i.putExtra(Intent.EXTRA_EMAIL, new String[]{ConnectionsManager.SEND_LOGS_EMAIL});
i.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildVars.SEND_LOGS_EMAIL});
i.putExtra(Intent.EXTRA_SUBJECT, "last logs");
i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(i, "Select email application."));
Expand Down
Loading

0 comments on commit 5141fc1

Please sign in to comment.