Where are SMS Drafts stored? - java

I have searched and searched and cannot seem to pull data from the draft's folder within the device. Basically I am wanting to pull the typed (unsent) message from the user's conversation, my thinking is that it was stored within Android as a draft. However if I try to search the draft folder using the uri-
Uri message = Uri.parse("content://sms/draft/");
No data is returned. I have adjusted it to remove the 'draft' portion and it does return all my inbox messages. I have ensured that the permissions have been set and accepted.

Related

send email to generic ID in lotus notes using notesFactory in java

Their is a requirement in a project to send emails from java application through lotus notes.
Note: the domino server is installed on client server.
Currently i am able to send email using notesFactory on my local machine.using notes.jar file
Which accesses the user by .nsf by its password.
I.e creating secure connection by password.
And gtting database object by calling
Session.getdatabase(null,"user.nsf")
Its perfectly working.
But for some types of emails the client have shared a generic id...(link) over an email... By clicking on that link the generic mail box opens under active user. In separate tab... Through which we can send emails.
But have not shared their .nsf path or id or password.
It directly opens by clicking on that link.
Now i want to access that generic id in notesfactory session
I tried to keep open that id and then running my code...but still it sends email through active user itself.
And client is not ready to share the id and password details of that user. Not the id file is getting generated in our local machine.
Is their any way to send emails through that id?
If anyone want code i am using..ill share.
But for some types of emails the client have shared a generic
id...(link) over an email... By clicking on that link the generic mail
box opens under active user. In separate tab... Through which we can
send emails.
That does not sound like a "shared id", it sounds more like a mail database with the ACL set to give a group of users access.
When you send an email from within Notes (no matter if it is through the UI or through code), the actual logged in user is used as the sender. It is intentionally by design, to prevent users from spoofing the sender.
There is an unsupported way to fake the sender address, by dropping the email directly into mail.box, but that should only be done by someone know what they are doing.
I wrote a script library several years ago, intended to help sending emails. It includes the ability to set the sender address. You can find it on my blog, it's free to use. But I would not recommend you using it without first understanding what the code is doing.
Here is the relevant part of the code:
Set mailbox = New NotesDatabase(mailservername,"mail.box")
If mailbox.Isopen = False Then
Print "mail.box on " & mailservername & " could not be opened"
Exit Sub
End If
Set me.maildoc = New NotesDocument(mailbox)
Call me.maildoc.ReplaceItemValue("Form","Memo")
Set me.body = New NotesRichTextItem(maildoc,"Body")
Call maildoc.ReplaceItemValue("Principal", me.p_principal)
' If principal is set, we want to fix so mail looks like
' it is coming from that address, need to set these fields
Call maildoc.ReplaceItemValue("From", me.p_principal)
Call maildoc.ReplaceItemValue("Sender", me.p_principal)
Call maildoc.ReplaceItemValue("ReplyTo", me.p_principal)
Call maildoc.ReplaceItemValue("SMTPOriginator", me.p_principal)
Call maildoc.ReplaceItemValue("PostedDate",Now())
If me.p_principal<>"" Then
Call maildoc.Save(True,False) ' Save in mail.box
Else
Call maildoc.Send(True) ' Send mail normally
End If
You use the Principal field to set the sender address.

Sending Play Framework File Uploads To Amazon S3

I have a Play (version 1.4) app currently hosted on Heroku that lets users create items for auction like eBay. The main process is the user fills out a form with information about the photo that is being uploaded. When the form is submitted the information is stored in a database. The photo however, I want to be stored using Amazon's S3 service. On success, the page that creates the auction item is directed to a page that shows the image with the information that was just uploaded.
I am probably more than half way there, because when my form submits, the image is successfully being sent to the bucket I created for it using S3. So that's good news. The bad news is, immediately upon submission, the app crashes, I get my "Oops!" error page, and when I check my database, none of the information was saved. The method responsible for creating the new auction item, doCreateItem(), the process I just described, where I am able to send the photo to AWS, but the app crashes not saving the data to the database, that method, looks like this:
public static void doCreateItem(#Valid AuctionItem item){
if (validation.hasErrors()){
params.flash();
validation.keep();
createAuctionItem();
}
// item.photo = new S3Blob();
// item.photo.set(new FileInputStream(item.photo), MimeTypes.getContentType(item.photo.getName()));
item.createdBy = Authenticate.getLoggedInUser();
item.save();
show(item.id);
}
https://github.com/cmazzochi81/java-play-app/blob/master/app/controllers/Application.java
And the stack trace, looks like this:
In the stack trace when it refers to this error:
Execution exception (In /app/controllers/Application.java around line 43)
Line 43 in my code is the following line where the method is trying to save the data to the database:
item.save();
Now when I uncomment out the two lines in the doCreateMethod()
item.photo = new S3Blob();
item.photo.set(new FileInputStream(item.photo)
When I do that, I'm not even able to push my app to Heroku. The error in the console says the constructor FileInputStream(S3Blob), is undefined:
I am trying to do the exact same thing James Ward does in this article:
https://www.jamesward.com/2011/09/13/sending-play-framework-file-uploads-to-amazon-s3
The GitHub repo for my project can be found here:
https://github.com/cmazzochi81/java-play-app
Your assistance would be greatly appreciated. I have worked extremely hard on this project, and it is this close to being done.
Thank you in advance,
CM

Gmail watch user inbox, history.getMessagesAdded is not returning the new message

Requirement is to sync mails from Gmail for an user into our CRM. The system in place is based on Google Pub/Sub which watches inbox of the user for any change and fires the notification to our HTTPs endpoint. More on this at Gmail cloud pub/sub.
Based on the above procedure we git history of changes. And then i am interested in only new messages, so history.getMessagesAdded is preferred as per this guide. Issue we are facing now is the first mail of a thread is not captured under messagesAdded all the subsequent messages are passing through our system.
Note: For the first mail, we do get push from Google. But when we try to get Messages added it turns out empty. Is there anything special needs to be done for the first mail of the thread or am i missing out something.
I was experiencing a very similar problem, and my mistake was that I was using the historyId from the push notification, the solution was to store the last known historyId on my database, so, every time I get a notification, I get the history from the id I have stored, not the one from the notification.
In my case, the historyId from the notification doesn't even make part of the history, maybe because of my watch restrictions: labelIds=['INBOX']
This is the google pub/sub notification:
{
message:
{
data: {"emailAddress": "user#example.com", "historyId": "9876543210"},
message_id: "1234567890",
}
subscription: "projects/myproject/subscriptions/mysubscription"
}
I was using the message.data.historyId, wich was causing the confusion!
The message.data, comes as a base64 encoded string, in this example I just decoded it!
Step by step for watching new e-mails on the inbox:
Do all the configuration in the google pub/sub.
Start watching the user with the filters you want (docs.: https://developers.google.com/gmail/api/v1/reference/users/watch)
Store the historyId obtained in the step 2
When receive the notification, get all the events (history) using the stored id as the startHistoryId parameter (docs: https://developers.google.com/gmail/api/v1/reference/users/history/list)
In the history list obtained on the step 4, look for the new messages: history.getMessagesAdded().
Update the last known history id in your database, so you don't need to deal with the whole history every time!
I hope it helps.

Spring IAMP Mail receiver not reading all emails everytime [duplicate]

I have a piece of code which uses spring integration's IMAP adapter to poll an inbox to read all incoming emails which are unread and that works perfectly. But if I open any email message and and then mark it as "unread" in my outlook inbox the poller doesn't fetch the marked email.
I can use the pop3 adapter which fetches all the email, but deletes them afterwords, but I want to keep the emails in my inbox and I want the poller to fetch all the email which are unseen.
Any suggestions to handle this problem? I been searching and reading articles on email adapters but didn't find anything useful.
Thanks in advance.
Looks like you need custom 'search-term-strategy'. From Spring Integration (SI) documentation:
By default, the ImapMailReceiver will search for Messages based on the default SearchTerm which is All mails that are RECENT (if supported), that are NOT ANSWERED, that are NOT DELETED, that are NOT SEEN and have not been processed by this mail receiver (enabled by the use of the custom USER flag or simply NOT FLAGGED if not supported). Since version 2.2, the SearchTerm used by the ImapMailReceiver is fully configurable via the SearchTermStrategy which you can inject via the search-term-strategy attribute. SearchTermStrategy is a simple strategy interface with a single method that allows you to create an instance of the SearchTerm that will be used by the ImapMailReceiver.
And here is a post from SI forum with funtastic Oleg's explanation: Server does not support RECENT or USER flags
And here you can find SI DefaultSearchTermStrategy: it's a place to determine how you should implement your own strategy. I guess, you case is:
This email server does not support RECENT flag, but it does support USER flags which will be used to prevent duplicates during email fetch.
Switch SI-mail logging level to DEBUG and take a look, which flag supports your email server.

Detect user login/logout xmpp google app engine

I am using Google App Engine in Java to send XMPP messages.
I would like to know if there is a way to check if a user is logged in to the system or logged out. So, when the user signs in, I would like to send him a welcome chat message and when he signs out I would like to notify my server code of the same.
I have tried the presence API but no luck so far.
Assuming you're referring to querying a user's presence via XMPP, keep in mind that this will only work if your App Engine account is authorized by that user. If you have already got that far, querying for presence (user logged in/logged out) is quite simple (source).
If a Google talk user has subscribed to an app (has accepted an invitation or has invited the app to chat), the app can discover the user's availability by looking for a POST to /_ah/xmpp/presence/available. If the user is subscribed and available, you can send them your application's presence and status:
// In the handler for _ah/xmpp/presence/available
XMPPService xmppService = XMPPServiceFactory.getXMPPService();
Presence presence = xmppService.parsePresence(req);
// Split the XMPP address (e.g., user#gmail.com)
// from the resource (e.g., gmail.CD6EBC4A)
String from = presence.getFromJid().getId().split("/")[0];
// Mirror the contact's presence back to them
xmppService.sendPresence(from, PresenceType.AVAILABLE, presence.getPresenceShow(), presence.getStatus());
To further clarify, your app receives automatic presence notifications via the following POST URL paths:
POSTs to /_ah/xmpp/presence/available/ signal that the user is available and provide the user's chat status.
POSTs to /_ah/xmpp/presence/unavailable/ signal that the user is unavailable.
POSTs to /_ah/xmpp/presence/probe/ request a user's current presence.
As an example, when user sally logs in, you'll get a POST request to /_ah/xmpp/presence/available/ which your server will then have to process. Then when sally logs out, you'll get a separate POST request to /_ah/xmpp/presence/unavailable/.

Categories

Resources