added sending message feature for android

This commit is contained in:
Navjot 2019-09-18 14:39:29 +05:30
parent af9afcb365
commit c86ab075b7
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
5 changed files with 39 additions and 38 deletions

View File

@ -78,7 +78,7 @@ void getnumthreads()
#ifdef _WIN32
DWORD_PTR dwProcessAffinity, dwSystemAffinity;
#elif __linux__
// cpu_set_t dwProcessAffinity;
cpu_set_t dwProcessAffinity;
#elif __OpenBSD__
int mib[2], core_count = 0;
int dwProcessAffinity = 0;
@ -87,13 +87,13 @@ void getnumthreads()
int dwProcessAffinity = 0;
int32_t core_count = 0;
#endif
// size_t len = sizeof(dwProcessAffinity);
// if (numthreads > 0)
// return;
size_t len = sizeof(dwProcessAffinity);
if (numthreads > 0)
return;
#ifdef _WIN32
GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinity, &dwSystemAffinity);
#elif __linux__
// sched_getaffinity(0, len, &dwProcessAffinity);
sched_getaffinity(0, len, &dwProcessAffinity);
#elif __OpenBSD__
len2 = sizeof(core_count);
mib[0] = CTL_HW;
@ -106,22 +106,22 @@ void getnumthreads()
else if (sysctlbyname("hw.ncpu", &core_count, &len, 0, 0) == 0)
numthreads = core_count;
#endif
// for (unsigned int i = 0; i < len * 8; i++)
// #if defined(_WIN32)
// #if defined(_MSC_VER)
// if (dwProcessAffinity & (1i64 << i))
// #else // CYGWIN/MINGW
// if (dwProcessAffinity & (1ULL << i))
// #endif
// #elif defined __linux__
// if (CPU_ISSET(i, &dwProcessAffinity))
// #else
// if (dwProcessAffinity & (1 << i))
// #endif
// numthreads++;
// if (numthreads == 0) // something failed
// numthreads = 1;
// printf("Number of threads: %i\n", (int)numthreads);
for (unsigned int i = 0; i < len * 8; i++)
#if defined(_WIN32)
#if defined(_MSC_VER)
if (dwProcessAffinity & (1i64 << i))
#else // CYGWIN/MINGW
if (dwProcessAffinity & (1ULL << i))
#endif
#elif defined __linux__
if (CPU_ISSET(i, &dwProcessAffinity))
#else
if (dwProcessAffinity & (1 << i))
#endif
numthreads++;
if (numthreads == 0) // something failed
numthreads = 1;
printf("Number of threads: %i\n", (int)numthreads);
}
extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, unsigned long long target)
@ -146,7 +146,7 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
# else
pthread_create(&threads[i], NULL, threadfunc, (void*)&threaddata[i]);
# ifdef __linux__
pthread_setschedparam(threads[i], 0, &schparam);
pthread_setschedparam(threads[i], SCHED_IDLE, &schparam);
# else
pthread_setschedparam(threads[i], SCHED_RR, &schparam);
# endif

View File

@ -45,7 +45,8 @@ requirements =
kivymd,
kivy-garden,
qrcode,
Pillow
Pillow,
msgpack
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes

View File

@ -1213,6 +1213,7 @@ class singleWorker(StoppableThread):
powStartTime = time.time()
initialHash = hashlib.sha512(encryptedPayload).digest()
trialValue, nonce = proofofwork.run(target, initialHash)
print("nonce calculated value#############################", nonce)
logger.info(
'(For msg message) Found proof of work %s Nonce: %s',
trialValue, nonce

View File

@ -1,7 +1,10 @@
from importlib import import_module
from os import path, listdir
from string import lower
try:
from kivy.utils import platform
except:
platform = ''
from debug import logger
import messagetypes
import paths
@ -32,7 +35,7 @@ def constructObject(data):
else:
return returnObj
if paths.frozen is not None:
if paths.frozen is not None or platform == "android":
import messagetypes.message
import messagetypes.vote
else:

View File

@ -13,28 +13,24 @@ class translateClass:
else:
return self.text
# def _translate(context, text, disambiguation = None, encoding = None, n = None):
# return translateText(context, text, n)
def _translate(context, text, disambiguation = None, encoding = None, n = None):
return text
return translateText(context, text, n)
# def _translate(context, text, disambiguation = None, encoding = None, n = None):
# return translateClass(context, text.replace('%','',1))
def translateText(context, text, n = None):
try:
enableGUI = state.enableGUI
except AttributeError: # inside the plugin
enableGUI = True
if enableGUI:
if not state.kivy and enableGUI:
try:
from PyQt4 import QtCore, QtGui
except Exception as err:
try:
if state.kivy:
pass
except Exception as err:
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
print 'Error message:', err
os._exit(0)
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
print 'Error message:', err
os._exit(0)
if n is None:
return QtGui.QApplication.translate(context, text)
else: