Fetch Black Berry 10 Call History - blackberry-10

i want to write an application to fetch call history from a black berry 10.
Can any body guide me which API i can use.

From the above link we can only display the default call log.

Would using the invocation framework work for what you are trying to do? It seems there is a way to fetch the call log.
https://developer.blackberry.com/cascades/documentation/device_platform/invocation/phone.html

This can be done using the CallHistoryService API available in OS 10.3.0
Here is some sample code to fetch all calls and output the numbers to the log:
CallHistoryService callHistoryService;
// The ID of a valid account is required
bb::pim::account::Account defaultAccount =
callHistoryService.defaultAccount();
// The default filter will return all calls
CallHistoryFilter defaultFilter;
// Contact search can be used to identify the contacts
CallHistoryParam callHistoryParams;
callHistoryParams.setContactSearchEnabled(false);
QList<CallEntryResult> callHistoryResults =
callHistoryService.callHistory(
defaultAccount.id(),
defaultFilter,
callHistoryParams);
foreach (const CallEntryResult &callEntryResult, callHistoryResults) {
CallEntry callEntry = callEntryResult.call();
qDebug << "Phone number: " << callEntry.phoneNumber();
}

Related

Google Scripts - sending email based on a cell value

This is the code I am currently trying to use to implement an email based on the cell value of C2 (see screenshot of Google sheets below).
function amberwarning() {
// Fetch the combined flow value
var combflowrange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("FloodEWS").getRange("C2");
var combflow = combflowrange.getValue();
// Check combined flow value
if (270 < combflow < 310){
// Fetch the email address
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Email").getRange("A2");
var emailAddress = emailRange.getValues();
// Send Alert Email.
var subject = 'Amber warning';
var message = 'It is possible that the Egger site will experience flooding in the coming hours. The advice is to be prepared to take action as combined river flows can increase very quickly during storms. Please keep up to date with the latest river levels for Hexham at <https://flood-warning-information.service.gov.uk/station/9006>. The latest flood warnings from the Environment Agency for Hexham are here <https://flood-warning-information.service.gov.uk/warnings?location=+hexham>. The latest MetOffice weather forecast can be found here <https://www.metoffice.gov.uk/weather/forecast/gcy2xzrne#?>. Please use all available information to inform your decision making. You will keep receiving an email as per each refresh of the latest data. The current combined flow from the North and South Tyne is' + combflow;
MailApp.sendEmail(emailAddress,subject,message);
}
}
The current error message I am receiving is "The parameters (number[],String,String) don't match the method signature for MailApp.sendEmail. (line 15, file"
The idea is that:
When cell C2 is between 270 and 310, to send an email 'Amber warning'
When cell C2 is above 310 send an email 'Red warning'
When cell C2 is less than 270, no email
This will hopefully be attached to a trigger to schedule every 15 mins
Any help on how to combine the two emails (or have single codes for each email) would be greatly appreciated.
enter image description here
It seems your "emailAddress" parameter is a number array (number[]) since the error you are receiving says so.
Try using getValue() if it is a single address, or get the first value of getValues() which is a 2D array by doing getValues()[0].
Whichever you choose, assign it to your emailAddress variable before calling MailApp.sendEmail().
Try to follow the steps in the documentation
as it explains everything clearly and how to send email through app-script

Fetching LogBook descriptors in custom firmware

I'm looking to fetch recorded data using LogBook in a custom Movesense firmware. How do I get the correct byte stream offset for the next GET call when receiving HTTP_CONTINUE?
I'm trying to implement these steps as described in DataStorage.md:
### /Logbook usage ###
To get recording from the Movesense sensors EEPROM storage, you need to:
1. Do **GET** on */Logbook/Entries*. This returns a list of LogEntry objects. If the status was HTTP_OK, the list is complete. If the result code is HTTP_CONTINUE, you must GET again with the parameter StartAfterId set to the Id of the last entry you received and you'll get the next entries.
2. Choose the Log that you are interested in and notice the Id of it.
3. Fetch the descriptors with **GET** to */Logbook/byId/<Id>/Descriptors*. This returns a bytestream with the similar HTTP_CONTINUE handling as above. However you **must** keep re-requesting the **GET** until you get error or HTTP_OK, or the Logbook service will stay "in the middle of the stream" (we hope to remove this limitation in the future).
4. Fetch the data with **GET** to */Logbook/byId/<Id>/Data*. This returns also a bytestream (just like the */Logbook/Descriptors* above).
5. Convert the data using the converter tools or classes. (To Be Continued...)
The problem is basically the same for step 3 and 4. I receive a whiteboard::ByteStream object in the onGetResult callback function but I don't know how to get the correct offset information from it.
I've found a number of different methods seemingly concerning different aspects of number of bytes in ByteStream.h (length, fullSize, transmitted, payloadSize and serializationLength) but I just can't get it working properly.
Basically I would like to do something like this in onGetResult:
if (resultCode == whiteboard::HTTP_CODE_CONTINUE) {
const whiteboard::ByteStream &byteStream = rResultData.convertTo<const whiteboard::ByteStream &>();
currentEntryOffset += byteStream.length();
asyncGet(WB_RES::LOCAL::MEM_LOGBOOK_BYID_LOGID_DESCRIPTORS(), AsyncRequestOptions::Empty, currentEntryIdToFetch, currentEntryOffset);
return;
}
The basic idea is to do the same call again.
So if you do:
asyncGet(WB_RES::LOCAL::MEM_LOGBOOK_BYID_LOGID_DESCRIPTORS(),AsyncRequestOptions::Empty, currentEntryIdToFetch);
and get the response HTTP_CONTINUE, do:
asyncGet(WB_RES::LOCAL::MEM_LOGBOOK_BYID_LOGID_DESCRIPTORS(),AsyncRequestOptions::Empty, currentEntryIdToFetch);
Until you get HTTP_CONTINUE or an error.
If the result code is HTTP_CONTINUE, you must GET again with the parameter StartAfterId set to the Id of the last entry you received and you'll get the next entries.
Might be a bit cryptic but do another asyncGet to the exact same resource until you get HTTP_OK or an http error code.
Also, note that you need to decode the data, a python script can be found here in this answer

Primefaces Push - What are the methods in <p:socket/> client widget

Can anybody point me to any api link which contains the <p:socket/> client widget?
Going through the push showcase I can only see connect method in
requestContext.execute("subscriber.connect('/" + username + "')");
What are the other methods.? Is there any disconnect method as-well.?
Also, how to create separate channel for each user (in case of chat application). I reckon, this <p:socket onMessage="handleMessage" channel="/chat/#{userSession.userId}" autoConnect="false" widgetVar="subscriber"/> will do the trick but apparantly it is not, atleast for me. Because by looking in the Chrome dev console I can see that everytime the page is refreshed it is appending the channel name (/chat/userid/userid...).
Any pointers is highly appreciated.!!!
I think I got the answer for some of the issue I'm facing.
For methods in push widget, push.js is the file to look for.
The appending issue is because of calling
requestContext.execute("subscriber.connect('/" + username + "')");
multiple time. The below code gets called which results in appending of the channel names multiple times.
connect: function (a) {if (a) {
this.cfg.request.url += a // <----
}
this.connection = $.atmosphere.subscribe(this.cfg.request)
Disconnect method is available in PF 4.0. or you can add the following code to push.js.
disconnect: function () {
this.connection.close()
}

How to implement API in my project

I'm developing an application for iPhone as my master thesis and it is my first experience with programming.
I'm doing an app that will scan barcode, taking ouf from code digits behind it, and then I need to send them to open source database and receive an answer with list of ingredients back.
So this info I found on one internet site.
The question is how I can implement THIS into my program?
It is possible to open the EAN database access from your own applications out of an EAN-query to perform.
This should happen with a simple HTTP GET request, the following format:
http://openean.kaufkauf.net/?ean = [ean] & & cmd = query queryid = [userid]
[Ean] here is the eight-or thirteen-digit EAN to be queried. How do you get a User ID [userid] for the field "queryid" can be found below.
The query was successful, you will receive data in text format (MIME type text / plain) back, which can look like this:
error = 0
name = Natural mineral
bath Vilbeler name = detail RIED source
vendor = H. Krone GmbH & CO.. KG
= maincat drinks, alcohol
subcat =
descr = Natural mineral water carbonated
origin = Germany
= 25% validated
Thanks
You can get the result stored into a string by doing the following
//Replace each var with your strings
NSString *request=[NSString stringWithFormat:#"http://openean.kaufkauf.net/?ean=%#&cmd=%#&queryid=%#%#",EANString,queryString,userIDString,EANString];
NSURL *urequest=[NSURL URLWithString:request];
//Assuming you are using UTF8StringEncoding
NSString *result=[[NSString alloc] initWithContentsOfURL:urequest encoding:NSUTF8StringEncoding error:nil];
//parse the result to get your data
//After you stop using result you can release it
[result release];
If you need further explanation on this let me know.
Edit:
I really don't know about the codes you are using nor about the SDK, though all you need to do after you have your scanner working is to get 3 pieces of data (this to construct your HTTPRequest) and those are EAN, query and userid.
After you have done this you will have to perform the request (first 2 lines of the code) this after you have replaced the values with your recently acquired data (EAN, query and userid).
Then all you have to do is to parse your results; the request will return you a string with the form of the quote from your post, so you will have to go through the string taking whatever you need from it.
Hopefully this was a bit more clear.

WMI and Win32_DeviceChangeEvent - Wrong event type returned?

I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access...
I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see.
The documentation (MSDN) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1.
Any ideas ?
Here's sample code :
public class WMIReceiveEvent
{
public WMIReceiveEvent()
{
try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");
watcher.EventArrived +=
new EventArrivedEventHandler(
HandleEvent);
// Start listening for events
watcher.Start();
// Do something while waiting for events
System.Threading.Thread.Sleep(10000);
// Stop listening for events
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive an event: " + err.Message);
}
}
private void HandleEvent(object sender,
EventArrivedEventArgs e)
{
Console.WriteLine(e.NewEvent.GetPropertyValue["EventType"]);
}
public static void Main()
{
WMIReceiveEvent receiveEvent = new WMIReceiveEvent();
return;
}
}
Well, I couldn't find the code. Tried on my old RAC account, nothing. Nothing in my old backups. Go figure. But I tried to work out how I did it, and I think this is the correct sequence (I based a lot of it on this article):
Get all drive letters and cache
them.
Wait for the WM_DEVICECHANGE
message, and start a timer with a
timeout of 1 second (this is done to
avoid a lot of spurious
WM_DEVICECHANGE messages that start
as start as soon as you insert the
USB key/other device and only end
when the drive is "settled").
Compare the drive letters with the
old cache and detect the new ones.
Get device information for those.
I know there are other methods, but that proved to be the only one that would work consistently in different versions of windows, and we needed that as my client used the ActiveX control on a webpage that uploaded images from any kind of device you inserted (I think they produced some kind of printing kiosk).
Oh! Yup, I've been through that, but using the raw Windows API calls some time ago, while developing an ActiveX control that detected the insertion of any kind of media. I'll try to unearth the code from my backups and see if I can tell you how I solved it. I'll subscribe to the RSS just in case somebody gets there first.
Well,
u can try win32_logical disk class and bind it to the __Instancecreationevent.
You can easily get the required info
I tried this on my system and I eventually get the right code. It just takes a while. I get a dozen or so events, and one of them is the device connect code.