Announcement

Collapse
No announcement yet.

New BT Mobilephone Plugin

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • New BT Mobilephone Plugin

    Do you use this plugin ?
    8
    Yes
    87.50%
    7
    No
    12.50%
    1
    Last edited by pierrotm777; 03-18-2016, 05:38 AM.

  • #2
    The original version of this plugin was created by Fox_Mulder here

    This is a new version that read all Phone Book data from your phone and save them into several custom list !
    Now, all Phone's infos are visible (that was an issue into the old code that request too quickly the info)!
    Check if SMS is received !

    Phone screen
    Click image for larger version

Name:	main.jpg
Views:	1
Size:	199.9 KB
ID:	2580043

    Contacts screen
    Click image for larger version

Name:	contacts.jpg
Views:	1
Size:	200.9 KB
ID:	2579834

    View Contacts
    Click image for larger version

Name:	view.jpg
Views:	1
Size:	90.5 KB
ID:	2580174

    Write contact
    Click image for larger version

Name:	eidt.jpg
Views:	1
Size:	86.6 KB
ID:	2580175

    Read Messages
    Click image for larger version

Name:	read.jpg
Views:	1
Size:	168.7 KB
ID:	2579836

    Write Messages
    Click image for larger version

Name:	write.jpg
Views:	1
Size:	153.7 KB
ID:	2579837

    Settings
    Click image for larger version

Name:	setting1.jpg
Views:	1
Size:	185.8 KB
ID:	2579839

    Click image for larger version

Name:	setting2.jpg
Views:	1
Size:	217.3 KB
ID:	2579840

    Check service screen:
    Click image for larger version

Name:	check.jpg
Views:	1
Size:	197.1 KB
ID:	2579998


    The plugin create a phone list of all devices paired with Bluesoleil !
    If your phone('s) are paired, go to the settings and select your device , and use the 'APPLY' button .
    !!! No need to rerun RR !!!

    Bluetooth Chipsets Supported
    BlueSoleil 10 supports mainstream chipsets such as CSR, Broadcom, ISSC, Texas Instruments, Atheros, 3DSP, Marvell, Accel Semiconductor, Conwise, etc. and supports more Bluetooth laptops, e.g. Lenovo ThinkPad, HP, Dell, Sony, ASUS, Samsung, TOSHIBA and LG etc.

    After the 1.1.6.0 , the plugin can run with the GpsLockout by Blue ZX3 plugin
    With this feature ON, the SMS screens are stopped when the car is in motion !
    For use this feature, edit the settings file MobilePhone.xml !
    <LockInMotion>true</LockInMotion>

    After the 1.1.7.1 , the plugin can translate a SMS message (before a SMS send or after a received SMS)
    For that, you need to install the plugin RRTANSLATOR .
    As soon as possible
    ----------oooooooo0000000000000oooooooo---------

    Bluesoleil Install
    See these explains on the Driveline thread

    How to configure the plugin: (AT version only)
    The best way is to check one time (first run) this option with true option (<PhoneBookListUpdate>true</PhoneBookListUpdate>) and see what phone book is found in your phone .
    For exemple, my Sony K610i return this list!
    <PhoneBookList>FD,LD,ME,SM,DC,RC,MC,MV,HP,BC</PhoneBookList>
    If you see the phone book ME,SM,DC,RC and MC then use these settings for all time !
    <PhoneBookListUpdate>false</PhoneBookListUpdate>
    <PhoneBookList>ME,SM,DC,RC,MC</PhoneBookList>

    After the version 1.1.7.0, each time you run RR, the phone book DC,RC and MC are always updated !
    And, if PhoneBookUpdate is set to true (<PhoneBookUpdate>true</PhoneBookUpdate>), ME and SM are also updated and a MT file is build.
    You must wait several minutes for obtain this MT file !
    MT = ME +SM .

    Speech recognition is now available !
    You must edit the last line of the .xml file if you want change the language !
    <PhoneSpeechNumbers>zero,one,two,three,four,five,six,seven,eight,nine, more,star,sharp,delete,cancel,call,stop call,help call,by name,-,-,-</PhoneSpeechNumbers>
    With the 1.2.6 version, you just need to change the language !!!!

    You can use 5 new events:
    ONMOBILEPHONESPEECHLOAD Raises an event when the phone speech recognition is loaded
    ONMOBILEPHONESPEECHUNLOAD Raises an event when the phone speech recognition is unloaded
    ONMOBILEPHONESPEECHHELP Raises an event when the phone speech recognition ask the speech help

    Change the last '-' by your own word:
    ONMOBILEPHONESPEECHSUPP1 Raises an event when the phone speech recognition ask the speech supplement 1
    ONMOBILEPHONESPEECHSUPP2 Raises an event when the phone speech recognition ask the speech supplement 2
    ONMOBILEPHONESPEECHSUPP3 Raises an event when the phone speech recognition ask the speech supplement 3

    SMS read and write:
    Your phone must understand the AT commands AT+CNMI=? , AT+CMTI=? and AT+CSCA=? .
    If CNMI command is accepted, try the command AT+CNMI=2,1,0,0,0 . If the return is OK, the ckeck SMS will be accepted !
    If CMTI command is accepted, try the command AT+CMTI=? . That must return you the number of SMS found .
    If the phone accept this command, the Sms Service Centre Address is saved automatically !
    ex: <SmsServiceCentreAddress>+33xxxxxxxxx</SmsServiceCentreAddress>

    For receive or send SMS, your phone must understand the AT command AT+CMGF=?.
    The plugin use the PDU mode AT+CMGF=0 for read or write the SMS (not the text mode AT+CMGF=1).

    For these tests, you can use the DEBUG ON window (RR command is MOBILEPHONE_DEBUGON )
    You can also edit the MobilePhone_ATCMD.lst file with the AT command you want to test !

    PS: I think the iPhone don't accepted this feature !
    ----------oooooooo0000000000000oooooooo----------

    ----------oooooo PBAP MAP PAN AVRCP Version (after v1.2.1) oooooo----------
    This new version use the ClockWork code in it's future DriveLine version .
    I must to say a great thank to him for this share !
    This new code extract directtly 5 vcard files and convert these vcard to RR Lists !!!
    PAN,MAP and AVRCP feature are added!
    This version begin with the V1.2.1 version !
    ----------oooooo PBAP MAP PAN AVRCP Version(after v1.2.1) oooooo----------

    ----------oooooo Know issue oooooo----------
    If you have found an incompatibility between BTMobilePhone and the Vehicule Maintenace plugin !
    If you have found an incompatibility between BTMobilePhone and the RRGoogleMapsTools plugin !
    In the BTMobilephone xml setting file , define RunOnStart as false !!!!!!
    It's result that the BT connection isn't done on RR start, but only when you click the first time on the button Phone(or 'MOBILEPHONE' RR command) !!!
    ----------oooooo Know issue oooooo----------

    ----------oooooo Check our phone oooooo----------
    You can check your phone without the plugin !
    For that use the BlueSoleilTest.exe create by ClockWork for its frontend Driveline!
    ----------oooooo Check our phone oooooo----------

    The plugin is ready for the skins:
    Carwings
    DFX5
    Reborn
    eLite2 800x600

    Download from Mediafire.com:
    RR Plugin BTMobilePhone (AT commands used) V1.1.7.2 Setup.zip

    RR Plugin BTMobilePhone (PBAP & MAP services) V1.6.9 Setup.zip

    You can use the last SDK , IVT_BlueSoleil 10.0.494.0 that run with this last version also !
    Don't use the SDK befor IVT_BlueSoleil 10.0.492.1 (no MAP service for iPhone user) !


    This plugin use also the RRTranslator and the Gpslockout plugins !


    Thanks to ClockWork for his help on this version !
    Last edited by pierrotm777; 01-01-2017, 05:31 AM.

    Comment


    • #3
      History:
      v1.6.9 27-12-2016
      -auto phone books update is now ON by default.
      -phone contacts are now read by the main timer only one time and if list need an update.
      -update translator code (SMS screens are updated).
      -a new option stop or not on startup the Bluetooth (<RestartBTBeforeStart>false</RestartBTBeforeStart>).
      now, by default, the Bluetooth isn't stopped on each startup (hope to have a quicker start).
      This feature is usable only manually (no screen button).
      -MOBILEPHONE_PHONEBOOKSORT function issue is solved.

      v1.6.8 16-12-2016
      -update resume feature solved.
      -update view contact info code for solve issue with label MOBILEPHONE_CONTACTSFROMPHONE.
      -add attach file option with send message.

      v1.6.7 5-12-2016
      -update on/off timers 1&2.
      Commands:
      MOBILEPHONE_TIMER1ONOFF and MOBILEPHONE_TIMER2ONOFF
      Indicators:
      MOBILEPHONE_TIMERREQUESTINFOS and MOBILEPHONE_TIMERCHECKDEVICEPRESENCE
      -update PAN service code.
      -birthday only checked one time or if the date change.
      -uncomment AT commands result code (AT+CIND? used for update signal and battery values).

      v1.6.6 26-11-2016
      -simplify sms extract code !
      -add new simplified format for history lists.
      -new command and label MOBILEPHONE_PHONEBOOKTYPE (switch from simplified list to normal, history list only)
      -solve issue in list that crached RR.
      -remove * character for all events.

      v1.6.5 31-10-2016
      -update sms code (add name and number) for iphone issue.
      -force call out screen to be loaded in all case.
      -update ringing code event.
      -update favorite code.
      -pictures are extracted for each number of a contact.
      -update history list code when no name and no datetime exist.
      -update history after a call in or call out.
      -update search picture code(decode international number).
      -update search name code(decode international number).

      v1.6.4 25-10-2016
      -add MOBILEPHONE_MAPSERVICE variable for disable SMS (MAP service).
      (1 or not define = ON and 0 = OFF).
      -add option select phone plugin (icards only).
      -update sms read code.
      -add attached file option in read sms screen.
      -limit sms popup.
      -change sms popup form (icards).

      v1.6.3 22-10-2016
      -after the first contacts extract, the list is now loaded !
      -popup 'contacts extract' added (icards).
      -remove sms popup.
      -update build and save vcard in phone(accept several number, phone's type and address).
      -remove re-format phone number code.

      v1.6.2 14-10-2016
      -rewrite contact's details and writer code.
      -sms message is now read in the good order.
      -double click on a contact call the number or load the numbers selector screen if several numbers are found for this contact.
      -favorite's screen accept now several numbers for one contact.

      v1.6.1 30-9-2016
      -update favorite issue (iCarDS).
      -update manual startup.
      -update settings after phone change (need quit RR or iCarDS).
      -change sms read screen (change message text from label to custom list).
      -update PAUSE and RESUME before and after call.
      -update VOLUME code before and after call.
      -change the iCards Language file to the good folder (C:\Program Files\TipTop software\iCar DS\Language\).
      -update uninstallation (ini files and cf_ind.txt file are now well restored).

      v1.6.0 13-9-2016
      -update load sms load screen's models(iCarDS).
      -add 'ACTIVATE;iCar DS' on load skipto screen (iCarDS).
      -the un-installer remove all plugin's files.
      -add 'send position' button into the sms screen writer (iCarDS).
      -update 'Lock In Motion' feature (ON by default. Block the SMS access when the car is in motion).
      -add external power check now run very well and checked each 10s (MOBILEPHONE_BATTERYCHARGING indicator return True or False. Need a USB connection).
      -remove extra characters from phone numbers in lists and photos (iphone issue).

      v1.5.9 9-9-2016
      -the un-installer will not uninstall add-ons skin files.
      -no sms popup and no auto add contact by default.
      -update events into the ExecTBL.ini file (iCarDS installer only).
      -add optional events into the ExecTBL.ini file (iCarDS installer only).
      -add ringing feature in car's speakers (need a ringin.wav file under ...iCar DS\Extentions\MobilePhone\RingTone\).
      You can change the ringin.wav file by your, the code adapt automatically the ringin length loop.

      v1.5.8 31-8-2016
      -add debug log file for the event HFP_Ringing.
      -update code and add debug log file for the event HFP_StandBy.

      v1.5.7 23-8-2016
      -add send gps position in write sms screen (Google Maps, Bing Maps and Yandex Maps).
      -update RR screens.
      -update sms read code (for uncomplet subject issue).

      v1.5.6 21-8-2016
      -update info code in sms read screen.
      -reset msg id between unread or all sms check.
      -add multilanguage for SMS screens and helps popup.
      -update lock in motion code.
      -update sms read code when gps is active.

      v1.5.5 16-8-2016
      -update SMS read code.
      -add multilanguage for Sms screens.
      -remove all SETVOL;MASTER;... command for iCarDS.

      v1.5.4 11-8-2016
      -update iCarDS screen for mac address issue in dial box.
      -update setting2 screen.
      -add code for the options 'No Add Contact' and 'No Sms Popup'.

      v1.5.3 10-8-2016
      -add change start delay (default is 3x5s maximum Must >=2 and <=5)

      v1.5.2 28-7-2016
      -add commands:
      mobilephone_stopallcheck stop or restart MAP and Network check (toogle command)
      mobilephone_stopallcheck;1 stop MAP and Network check.
      mobilephone_stopallcheck;0 restart MAP and Network check.
      -add stop add contact (set PhoneNoAddContact = true).
      -add stop no popup info (set PhoneNoPopupInfo = true).
      -limit number of popup.
      -add Tools folder.
      -update second phone code in settings.

      v1.5.1 26-7-2016
      -add read sms iphone compatibility?

      v1.5.0 25-7-2016
      -update favorite icards screen.
      -update mobilecall icards screen.
      -update models icards screen.
      -update viewentry code.
      -add sort list when hold the vcard extract button(icards).
      -update view and build contact screens (complete addresse an birthday added).
      -stop auto unread sms if all sms read is used .
      -change enter settings code.

      v1.4.9 18-7-2016
      -update main code !
      -update contact's address infos.
      -add favorites to sms write screen.
      -all iCarDS screens are ready!

      v1.4.8 14-7-2016
      -update favorites code.
      -add *ONMOBILEPHONEALLRESUME RR event.
      -update contact's list (check only contact with phone number).

      v1.4.7 22-6-2016
      -remove /DISCARDABLE in contact's screen that clear custom list.
      -remove alarm code(used only AT commands). Need to delete xml settings file.
      -MOBILEPHONE_DIAL;$VAR$ accepted.
      -add add, del and call favorites contacts screen code (10 favorites by default but more is possible).
      -add emergency and voice mail number in multilanguage name.
      -PAN service now run very well (if your phone accept this feature).
      -add auto run and stop PAN service code (need 9s for this check):
      PAN auto stop if Wifi or LAN connection is found.
      PAN auto start if Wifi and LAN connections are lost.
      -add help button on contacts and favorites screens.
      -move some log position for better read.
      -update skins (DFX5,Reborn,Carwings and eLite2_800x600).
      -add HELP button.
      -save old volume before a SAY command (for read sms or listen to a new call).
      -restore old volume after a SAY command.
      -save and restore volume after AVRCP use.
      -save and restore volume when phone return to standby mode (after a call).
      -MAP is now checked only each 60s .
      -add GPSVALID2 (idem original GPSVALID but return always 'True' or 'False' and not 'Vrai' or 'Faux' like in french).
      -add send SMS command (for alarm or what you want)
      MOBILEPHONE_SENDSMS;0102030405;text
      MOBILEPHONE_SENDSMS;$MyNumber$;$MyText$

      v1.4.6 27-5-2016
      -force PAUSE audio sources with InCall mode.
      -update MOBILEPHONE_DIAL;111 and MOBILEPHONE_DIALBYNAME;bbb code.
      (MOBILEPHONE_DIAL;EMERGENCY or MOBILEPHONE_DIAL;MSGVOCAL or MOBILEPHONE_DIAL;111 accepted).
      -update MOBILEPHONE_DIAL code.
      -save old volume and resume old volume value after each call.

      v1.4.5 26-5-2016
      -Add attach file info into SMS notification.
      -Add speech to text feature with SMS notification (multilanguage ready).
      -debug code for iCarDS.
      -build chameleon skin for iCarDS.
      -check birthday just one time.
      -add multilanguage code.
      -update number of unread messages code.

      v1.4.4 16-5-2016
      -Update phone book extract code for compatibility with international number.
      -Add MOBILEPHONE_CLEAR in Reborn skin .
      -Update AVRCP check.
      -Update Roaming RR event(send only one time).
      -Update SMS extract, read and notification code.
      -Change beta status to normal.

      v1.4.3 10-5-2016
      -Update new unread SMS check code (replace timer by a counter).
      -Update remote service code (RR crash is solved).

      v1.4.2 8-5-2016
      -Update new unread SMS check code.
      -Update remote service code.

      v1.4.1 7-5-2016
      -Add new timer (60s) for check new unread SMS presence.
      -Add plugin operating time.

      v1.4.0 6-5-2016
      -Update MOBILEPHONE_SYSINFO code (error in 64bits).
      -Add code for check if file MobilePhone.xml is the last (old settings are saved)
      -First version usable by iCarDS.
      -Add Local services list.
      -Update remote services list code.
      -Add some other log code .
      -Add indicator code for battery and signal.

      v1.3.9 24-4-2016
      -Add some log info.
      -Update log file code.
      -Add WAIT phone mode (you can quit your car the plugin disconnect the HFP service and come back to the car and the phone is reconnected)
      -Add SWAP phone feature (if two phones are defined in settings, you can change to the second phone)
      -Set sliders to 0 if phone is disconnected.
      -Add system informations code.
      -Update manual connection code.
      -Add multi language code.
      -Update Country Prefix number code.

      v1.3.8 21-4-2016
      -Change the code for load the plugin.

      v1.3.7 19-4-2016
      -Add MOBILEPHONE_PHONEBOOKSORT (return the pb.vcf and MobilePhone_PB.txt files in good order).
      -Update the viewer vcard code (now accept if the vcard and the RR list are not synchronised)
      -Update eLite2 skin.
      -Change code that load the plugin through a BackgroundWorker.

      v1.3.6 12-4-2016
      -Add MOBILEPHONE_SETSOURCE;AVRCP and MOBILEPHONE_SETSOURCE;NONE
      -Add a new threads for initiate the plugin(hope that solve the RR crash issue).
      -Add blink indicator vcard update for first vcard extract !
      -Change code when phone receive a standby event(vcard update is moved into the outgoincall event)
      -Add second phone settings code.

      v1.3.5 7-4-2016
      -Add auto vcard update after each call (need to set PhoneBookAutoUpdate to true in the settings).
      -Update Reborn settings screen (bad rssi signal indicator).
      -Add commands MOBILEPHONE_PHONEBOOKGET;XX and MOBILEPHONE_ADDITEM;MYLIST,0102030405,name .
      -Added Reborn themes colors, and update the screens MOBILEPHONE_ENTRY.skin and MOBILEPHONE_CONTACT_EDIT.skin.
      -Check if the language selected has its own variables language list under the folder Languages.
      -Add ACTIVESOURCE label info . When the AVRCP player is used, ACTIVESOURCE = AVRCP Player and ACTIVESOURCEID return 10.
      -Update code around GpsLockout.

      v1.3.4 6-4-2016
      -Add black list code for the MOBILEPHONE_CONTACT_EDIT.skin and MOBILEPHONE_ENTRY.skin screens.
      (update add a contact, update delete a contact and reset black list)
      -Update the code around the MOBILEPHONE_SETTINGS.skin (device selected is always the phone connected).
      -Update speech recognition code (recognition ins't only for US language).
      -Update MOBILEPHONE_SETTINGS2.skin screen for GTRANSLATOR compatibility.
      -Add 'vCard Extract' button into the MOBILEPHONE_CONTACTS.skin screen .
      -Update the installer code .

      v1.3.3 27-3-2016
      -Now, the variable MOBILEPHONE_PHOTOPATH in the MOBILEPHONE screen, is always updated.
      -Add ROAMING indicator.
      -PhoneExecATCmd setting is now set to TRUE by default.
      It's important for have return of external power run on off.
      -Add delete one phone number in black list.
      -Add reset black list.
      -Value returned by the label MOBILEPHONE_SPEECHCULTURE is now the good language.
      -Settings screens update.
      -Accept international and national phone format and return the good contact's picture if exist .
      Need the settings:
      <PhoneCountryCodes>
      <string>0</string>
      <string>33</string>
      <string>00</string>
      </PhoneCountryCodes>
      Where for the france:
      0 = networkCarrierCode
      33 = countryCode
      00 = internationalCarrierCode

      v1.3.2 25-3-2016
      -Add button A2DP service
      -Add several labels
      -Update check services screen for Reborn,DFX5 and elite2
      -Add player code and update player screen.
      -Add tempo on plugin start
      If RR crash , try to edit the setting PhoneStartupTimer (minimum=5 and maximum=60).

      v1.3.1 22-3-2016
      -Speaker volume accept now 0 to maximum.
      -Speaker volume is set to maximum on start (15)
      -Micro and speaker volume are now ready for use (0 to 15)
      mobilephone_microvolume;x where x = 0 to 15
      mobilephone_speakervolume;x where x = 0 to 15
      -Found a big issue that crashed RR with the plugins RRVehicleMaintenance or RRGoogleMapsTools
      -Add interface from contact's address to Google Maps view.
      -Debug file is deleted after each RR start !
      -Change the priority thread from normal to low (think to solve some RR crash)

      v1.3.0 19-3-2016
      -MOBILEPHONE_EDIT_ENTRY command is replaced by the command MOBILEPHONE_NEWENTRY
      -You can select a contact unknown in all list and edit it for after add it into your phone (Hold View button)
      -Add unicode log debug file (MobilePhone.log)
      -Add error handler popup

      v1.2.9 18-3-2016
      -Add birthday check (new icon button on the MOBILPHONE.skin screen)
      -Change search devices list for not have disconnection
      -Add automatic reconnection feature (can look for two phones)
      -When you click on a contact the contact's viewer read the infos of this contact
      -Update Crawings contact's editor screen for a easier use
      -Add birthday line into the Obex\NewCard.vcf file

      v1.2.8 16-3-2016
      -Pan IP address is now well updated into the screen pop-up.
      -Update one phone list only is now possible.
      -Add black list number in list.
      -Add new contact build.
      -Solved issue when a contact haven't a phone number.
      -Solved issue when several phones found for one contact and no address.
      -Add contact's organisation info
      -Add OPP service(copy a new contact into your phone). Thanks to ClockWork for this new feature :-)
      -Add A2DP service. Thanks to ClockWork for this new feature :-)
      -Add create new contact and save it to phone (OPP service used)
      -Solved bad disconnection on RR exit (Thanks ClockWork)
      -Add onresume and onsuspend support ?
      -Add MAP notification (SMS unread check only)

      v1.2.7
      -Pan service is now set on or off.
      -Carwings, DFX5, Reborn and eLite2 800x600 skins are ready for this version.

      v1.2.1
      -This new version run with the complete BlueSoleil SDK and accept the services:
      PBAP (Phone Book)
      MAP (Messages)
      AVRCP (Media player)
      PAN
      Last edited by pierrotm777; 01-01-2017, 05:32 AM.

      Comment


      • #4
        Pierrotm777,
        I have not loaded the new version yet but I have the vcard option working but how do I get the photos to update all of the .txt files instead of going in each phone txt file to update?
        Gee

        Comment


        • #5
          Originally posted by navputer View Post
          Pierrotm777,
          I have not loaded the new version yet but I have the vcard option working but how do I get the photos to update all of the .txt files instead of going in each phone txt file to update?
          The photo are automaticaly extracted with the vcard !
          You will found them into the Photo directory !

          Comment


          • #7
            We can't share files as dll in this new forum version ?

            Comment


            • #8
              And also no longer compatible with Tapatalk

              Comment


              • #9
                Hum , i have found some issue with certain vcard format !
                1- If a contact have not phone number, the code return an error ( solved)
                2- If a contact has more than one phone number and not address, the code don't read this contact and the other contacts after this contact!

                Comment


                • #10
                  Let me know if the bug is in my vcard module and I will look into it this weekend.

                  Comment


                  • #11
                    Originally posted by ClockWorK View Post
                    Let me know if the bug is in my vcard module and I will look into it this weekend.
                    Yes , it is and i wanted to feed back you my last code !
                    I have found that the last code was stopped when a contact has more than one phone and no address !
                    So, i have changed your code like that !!!!
                    Code:
                    Public Sub Bluesoleil_LoadContactsFile()
                    
                            On Error Resume Next 'solve the issue if a contact has more than one phone and no address
                    
                            Dim vcfFileName As String = MainPath & "PhoneBook\pb.vcf"
                            If File.Exists(vcfFileName) = False Then Exit Sub
                    
                            Dim vcfCardOffsets(0 To 0) As Long
                            Dim vcfCardCount As Integer = 0
                    
                    
                            vcfCardCount = VCard_GetContactOffsets(vcfFileName, vcfCardOffsets, "")
                    
                            Dim i As Integer
                            PhoneBookEntryCount = 0
                    
                            For i = 0 To vcfCardCount - 1
                    
                                Dim cardName As String = "", cardPhoneNumbers(0 To 0) As String, cardPhoneLabels(0 To 0) As String, cardPhoneCount As Integer = 0, cardPhoneAddress(0 To 0) As String, cardPhoneAddressCount As Integer
                                Dim cardEmail As String = ""
                                Dim cardImage As Bitmap = Nothing
                                Dim tempImage As Bitmap = Nothing
                                Dim cardDateTime As String = ""
                                Dim cardBirthDay As String = ""
                                Dim cardGeoPosition As String = ""
                                Dim cardNote As String = ""
                                Dim en As New CultureInfo("en-US")
                    
                                VCard_GetContactInfo(vcfFileName, vcfCardOffsets(i), cardName, cardEmail, cardPhoneNumbers, cardPhoneLabels, cardPhoneCount, tempImage, cardDateTime, cardPhoneAddress, cardPhoneAddressCount, cardBirthDay, cardGeoPosition, cardNote)
                    
                                If IsNothing(tempImage) = False Then
                                    'Try
                                    cardImage = New Bitmap(tempImage)
                                    'Catch ex As Exception
                    
                                    'End Try
                                    tempImage.Dispose()
                                    tempImage = Nothing
                                Else
                                    cardImage = Nothing
                                End If
                    
                                Dim j As Integer
                    
                    
                                ReDim Preserve PhoneBookEntries(0 To PhoneBookEntryCount)
                                PhoneBookEntries(PhoneBookEntryCount).EntryName = cardName
                                PhoneBookEntries(PhoneBookEntryCount).EntryImage = cardImage
                    
                                PhoneBookEntries(PhoneBookEntryCount).EntryPhoneNumberCount = cardPhoneCount
                                If cardEmail <> "" Then
                                    PhoneBookEntries(PhoneBookEntryCount).EntryEmail = cardEmail
                                End If
                                If cardBirthDay <> "" Then
                                    PhoneBookEntries(PhoneBookEntryCount).EntryBirthDay = DateTime.ParseExact(cardBirthDay, "yyyyMMdd", en)
                                End If
                                If cardGeoPosition <> "" Then
                                    PhoneBookEntries(PhoneBookEntryCount).EntryGeoPosition = cardGeoPosition
                                End If
                                If cardNote <> "" Then
                                    PhoneBookEntries(PhoneBookEntryCount).EntryNote = cardNote
                                End If
                    
                                ReDim PhoneBookEntries(PhoneBookEntryCount).EntryPhoneNumbers(0 To cardPhoneCount - 1)
                                For j = 0 To cardPhoneCount - 1
                                    PhoneBookEntries(PhoneBookEntryCount).EntryPhoneNumbers(j).EntryPhoneNumber = cardPhoneNumbers(j)
                                    PhoneBookEntries(PhoneBookEntryCount).EntryPhoneNumbers(j).Location = cardPhoneLabels(j)
                                    If cardPhoneAddress(j) <> "" Then
                                        PhoneBookEntries(PhoneBookEntryCount).EntryPhoneNumbers(j).Address = cardPhoneAddress(j)
                                    End If
                                Next
                    
                                PhoneBookEntryCount = PhoneBookEntryCount + 1
                    
                            Next i
                    
                        End Sub
                    The code into the VCard_GetContactInfo function is:
                    Code:
                    Public Sub VCard_GetContactInfo(ByVal vCardFileName As String, ByVal vCardOffset As Long, ByRef retCardName As String, ByRef retCardEmail As String, ByRef retPhoneNumbers() As String, ByRef retPhoneLabels() As String, ByRef retPhoneCount As Integer, ByRef retImage As Bitmap, ByRef retLastCallDateTime As String, ByRef retAddresses() As String, ByRef retAddressCount As Integer, ByRef retBirthDay As String, ByRef retGeoPosition As String, ByRef retNote As String)
                    
                            Dim hFile As IntPtr = FileAPI_OpenFile(vCardFileName, False)
                    
                            Dim inpFLen As Long = FileAPI_GetFileSize(hFile)
                    
                            FileAPI_SetFileOffset(hFile, vCardOffset)
                    
                            Dim tempLine As String = ""
                            Dim tempLineType As String = "", tempSubType As String = "", tempValue As String = ""
                            Dim retNamePrefix As String = "", retNameSuffix As String = ""
                    
                            retCardName = ""
                            retCardEmail = ""
                            retPhoneCount = 0
                            retAddressCount = 0
                            retBirthDay = ""
                            retGeoPosition = ""
                            retNote = ""
                            retLastCallDateTime = Nothing
                    
                            ReDim retAddresses(0 To 0)
                            ReDim retPhoneNumbers(0 To 0)
                            ReDim retPhoneLabels(0 To 0)
                            retImage = Nothing
                    
                            Dim tempDateTime As String = ""
                    
                            Do
                                If FileAPI_IsEOF(hFile) <> False Then Exit Do
                    
                                tempLine = ""
                                FileAPI_ReadLineFromBinaryFile(hFile, -1, inpFLen, vbLf, tempLine)
                                tempLine = Replace(tempLine, vbCr, "")
                    
                                VCard_GetLineInfo(tempLine, tempLineType, tempSubType, tempValue)
                    
                                If tempLineType = "PHOTO" Then
                    
                                    'check encoding.  if not base64, then it's probably a path or URL to a file.
                                    '
                                    ''  need to do this.  maybe not, since error-handlers will handle it.
                    
                                    'process base64 data.  get multi-line data.
                                    Dim imgData As String = tempValue
                    
                                    Do
                                        tempLine = ""
                                        FileAPI_ReadLineFromBinaryFile(hFile, -1, inpFLen, vbLf, tempLine)
                                        tempLine = Replace(tempLine, vbCr, "")
                    
                                        If Strings.Left(tempLine, 1) <> " " Then
                                            'no longer in image data.  take the image data and make an image object...
                    
                    
                                            'base64 data length should be a multiple of 4.  let's pad it if necessary so .Net doesn't cry about it.
                                            If Len(imgData) Mod 4 <> 0 Then
                                                imgData = imgData & "="
                                            End If
                                            If Len(imgData) Mod 4 <> 0 Then
                                                imgData = imgData & "="
                                            End If
                                            If Len(imgData) Mod 4 <> 0 Then
                                                imgData = imgData & "="
                                            End If
                    
                                            'perform base64 to byte-array conversion.
                                            Dim retImageBytes(0 To 0) As Byte
                    
                                            Try
                                                retImageBytes = Convert.FromBase64String(imgData)
                                            Catch ex As Exception
                                                ReDim retImageBytes(0 To 0)
                                            End Try
                    
                                            'convert byte array to image.
                                            Dim tempStream As New IO.MemoryStream(retImageBytes)
                                            tempStream.Position = 0
                                            Dim tempImage As Bitmap = Nothing
                                            Try
                                                tempImage = CType(Bitmap.FromStream(tempStream), Bitmap)
                                                retImage = tempImage
                                            Catch ex As Exception
                    
                                            End Try
                                            tempImage = Nothing
                                            tempStream.Dispose()
                    
                                            'get line info, since we're not in image data anymore.
                                            VCard_GetLineInfo(tempLine, tempLineType, tempSubType, tempValue)
                                            Exit Do
                                        Else
                                            imgData = imgData & Mid(tempLine, 2)
                                        End If
                    
                                    Loop
                                End If
                    
                    
                                Select Case tempLineType
                    
                                    Case "END"
                                        If tempValue = "VCARD" Then Exit Do
                    
                                    Case "FN"
                                        retCardName = tempValue
                                        retCardName = VCard_CleanUnicode(retCardName)
                                        retCardName = retCardName
                    
                                    Case "N"
                                        If retCardName = "" Then
                                            retCardName = tempValue
                                            retCardName = VCard_CleanUnicode(retCardName)
                                            retCardName = retCardName
                                        End If
                    
                                    Case "TITLE"
                                        If retCardName <> "" Then
                                            If tempValue <> "" Then
                                                retCardName = tempValue & " " & retCardName
                                            Else
                                                VCard_SeparateNameParts(retCardName, "", "", "", retNamePrefix, retNameSuffix)
                                                retCardName = retNamePrefix & " " & retCardName & " " & retNameSuffix
                                            End If
                                        End If
                    
                                    Case "TEL"
                                        ReDim Preserve retPhoneNumbers(0 To retPhoneCount)
                                        ReDim Preserve retPhoneLabels(0 To retPhoneCount)
                                        retPhoneNumbers(retPhoneCount) = tempValue
                                        retPhoneLabels(retPhoneCount) = tempSubType
                                        retPhoneCount = retPhoneCount + 1
                    
                                    Case "EMAIL"
                                        If retCardEmail = "" Then
                                            retCardEmail = tempValue
                                            retCardEmail = VCard_CleanUnicode(retCardEmail)
                                            retCardEmail = retCardEmail
                                        End If
                    
                                    Case "X-IRMC-CALL-DATETIME"
                                        retLastCallDateTime = tempLineType & " " & tempSubType & " " & tempValue 'VCard_ConvertStringToDateTime(tempValue)
                    
                                    Case "ADR" '
                                        Dim tempPObox As String = "", tempExtAddr As String = "", tempStreetAddr As String = "", tempLocalityCity As String = ""
                                        Dim tempRegionState As String = "", tempPostalCode As String = "", tempCountry As String = "", tempFormattedAddress As String = ""
                                        'VCard_SeparateAddressParts(tempValue, "", "", "", "", "", "", "", tempFormattedAddress)
                                        VCard_SeparateAddressParts(tempValue, tempPObox, tempExtAddr, tempStreetAddr, tempLocalityCity, tempRegionState, tempPostalCode, tempCountry, tempFormattedAddress)
                                        ReDim Preserve retAddresses(0 To retAddressCount)
                                        'retAddresses(retAddressCount) = tempFormattedAddress
                                        retAddresses(retAddressCount) = VCard_CleanUnicode(tempPObox & " " & tempExtAddr & " " & tempStreetAddr & " " & tempLocalityCity & " " & tempRegionState & " " & tempPostalCode & " " & tempCountry) 'tempFormattedAddress
                                        retAddressCount = retAddressCount + 1
                    
                                    Case "BDAY"
                                        If retBirthDay = "" Then
                                            retBirthDay = tempValue
                                            retBirthDay = VCard_CleanUnicode(retBirthDay)
                                        End If
                    
                                    Case "GEO"
                                        If retGeoPosition = "" Then
                                            retGeoPosition = tempValue
                                            retGeoPosition = VCard_CleanUnicode(retGeoPosition)
                                            retGeoPosition = UCase(retGeoPosition).Replace("GEO:", "")
                                        End If
                    
                                    Case "NOTE"
                                        If retNote = "" Then
                                            retNote = tempValue
                                            retNote = VCard_CleanUnicode(retNote)
                                            retNote = retNote
                                        End If
                    
                                End Select
                          
                            Loop
                    
                            FileAPI_CloseFile(hFile)
                    
                        End Sub
                    Into the RR interface, i use the code like that:
                    Code:
                    Case "mobilephone_viewentry"
                                    Try
                                        Dim ent As Integer = 0
                                        SDK.SetUserVar("mobilephone_cardid", (vcarId + 1).ToString)
                                        SDK.SetUserVar("mobilephone_cardphonecount", PhoneBookEntries(vcarId).EntryPhoneNumberCount.ToString)
                                        SDK.SetUserVar("mobilephone_cardfullname", PhoneBookEntries(vcarId).EntryName)
                    
                                        'check if one phone number exist
                                        If PhoneBookEntries(vcarId).EntryPhoneNumberCount > 0 Then
                                            For ent = 0 To PhoneBookEntries(vcarId).EntryPhoneNumberCount - 1
                                                SDK.SetUserVar("mobilephone_cardphonenumber" & ent, PhoneBookEntries(vcarId).EntryPhoneNumbers(ent).EntryPhoneNumber)
                                                SDK.SetUserVar("mobilephone_cardphonelabel" & ent, PhoneBookEntries(vcarId).EntryPhoneNumbers(ent).Location)
                                                If PhoneBookEntries(vcarId).EntryPhoneNumbers(ent).Address <> "" Then
                                                    SDK.SetUserVar("mobilephone_cardaddress" & ent, PhoneBookEntries(vcarId).EntryPhoneNumbers(ent).Address)
                                                Else
                                                    SDK.SetUserVar("mobilephone_cardaddress" & ent, "")
                                                End If
                                            Next
                                            'check if a contact use more than 1 phone number
                                            If PhoneBookEntries(vcarId).EntryPhoneNumberCount > 1 Then
                                                SDK.SetUserVar("mobilephone_cardothernumber", "+")
                                            Else
                                                SDK.SetUserVar("mobilephone_cardothernumber", "")
                                            End If
                                            SDK.SetUserVar("mobilephone_cardphonenumber", SDK.GetUserVar("mobilephone_cardphonenumber" & vcarIdOther))
                                            SDK.SetUserVar("mobilephone_cardphonelabel", SDK.GetUserVar("mobilephone_cardphonelabel" & vcarIdOther))
                                            SDK.SetUserVar("mobilephone_cardaddress", SDK.GetUserVar("mobilephone_cardaddress" & vcarIdOther))
                                            If File.Exists(sPhotoPath & PhoneBookEntries(vcarId).EntryPhoneNumbers(0).EntryPhoneNumber & ".jpg") = True Then
                                                SDK.SetUserVar("mobilephone_cardimage", sPhotoPath & PhoneBookEntries(vcarId).EntryPhoneNumbers(0).EntryPhoneNumber & ".jpg")
                                            Else
                                                SDK.SetUserVar("mobilephone_cardimage", sPhotoPath & "unknow.gif")
                                            End If
                                        Else
                                            SDK.SetUserVar("mobilephone_cardothernumber", "")
                                            SDK.SetUserVar("mobilephone_cardphonenumber", "")
                                            SDK.SetUserVar("mobilephone_cardphonelabel", "")
                                            SDK.SetUserVar("mobilephone_cardaddress", "")
                                            SDK.SetUserVar("mobilephone_cardimage", sPhotoPath & "unknow.gif")
                    
                                        End If
                                        If PhoneBookEntries(vcarId).EntryEmail <> "" Then
                                            SDK.SetUserVar("mobilephone_cardemail", PhoneBookEntries(vcarId).EntryEmail)
                                        Else
                                            SDK.SetUserVar("mobilephone_cardemail", "")
                                        End If
                                        If PhoneBookEntries(vcarId).EntryBirthDay <> "" Then
                                            SDK.SetUserVar("mobilephone_cardbirthday", PhoneBookEntries(vcarId).EntryBirthDay)
                                            SDK.SetUserVar("mobilephone_cardage", Convert.ToString(GetCurrentAge(PhoneBookEntries(vcarId).EntryBirthDay)))
                                        Else
                                            SDK.SetUserVar("mobilephone_cardbirthday", "")
                                            SDK.SetUserVar("mobilephone_cardage", "")
                                        End If
                                        If PhoneBookEntries(vcarId).EntryNote <> "" Then
                                            SDK.SetUserVar("mobilephone_cardnote", PhoneBookEntries(vcarId).EntryNote)
                                        Else
                                            SDK.SetUserVar("mobilephone_cardnote", "")
                                        End If
                                        If PhoneBookEntries(vcarId).EntryGeoPosition <> "" Then
                                            SDK.SetUserVar("mobilephone_cardgeoposition", PhoneBookEntries(vcarId).EntryGeoPosition)
                                        Else
                                            SDK.SetUserVar("mobilephone_cardgeoposition", "")
                                        End If
                                        'SDK.SetUserVar("mobilephone_cardorganisation", "")
                    
                                        SDK.Execute("LOAD;MOBILEPHONE_ENTRY.SKIN")
                                    Catch ex As Exception
                                        MessageBox.Show(ex.Message)
                                    End Try
                                    ProcessCommand = 2
                                Case "mobilephone_viewentrymore"
                                    vcarIdOther = 0
                                    If vcarId < PhoneBookEntryCount - 1 Then
                                        vcarId += 1
                                    End If
                    
                                    SDK.Execute("mobilephone_viewentry")
                                    ProcessCommand = 2
                                Case "mobilephone_viewentryless"
                                    vcarIdOther = 0
                                    If vcarId > 0 Then
                                        vcarId -= 1
                                    End If
                                    SDK.Execute("mobilephone_viewentry")
                                    ProcessCommand = 2
                                Case "mobilephone_viewentryfirst"
                                    vcarIdOther = 0
                                    vcarId = 0
                                    SDK.Execute("mobilephone_viewentry")
                                    ProcessCommand = 2
                                Case "mobilephone_viewentrylast"
                                    vcarIdOther = 0
                                    vcarId = PhoneBookEntryCount - 1
                                    SDK.Execute("mobilephone_viewentry")
                                    ProcessCommand = 2
                                Case "mobilephone_cardothernumber"
                                    If PhoneBookEntries(vcarId).EntryPhoneNumberCount > 1 Then
                                        vcarIdOther += 1
                                        If vcarIdOther = PhoneBookEntries(vcarId).EntryPhoneNumberCount Then
                                            vcarIdOther = 0
                                        End If
                                        SDK.SetUserVar("mobilephone_cardphonenumber", SDK.GetUserVar("mobilephone_cardphonenumber" & vcarIdOther))
                                        SDK.SetUserVar("mobilephone_cardphonelabel", SDK.GetUserVar("mobilephone_cardphonelabel" & vcarIdOther))
                                        SDK.SetUserVar("mobilephone_cardaddress", SDK.GetUserVar("mobilephone_cardaddress" & vcarIdOther))
                                    End If
                                    SDK.Execute("LOAD;MOBILEPHONE_ENTRY.SKIN")
                                    ProcessCommand = 2
                    It's important to check :
                    If PhoneBookEntries(vcarId).EntryPhoneNumberCount > 0
                    Last edited by pierrotm777; 03-11-2016, 09:46 AM.

                    Comment


                    • #12
                      I have also modified the code that build a new contact int format vcard 3.0 (the goal is to use a picture file that exist on the disk):
                      Code:
                          Public Sub VCard_WriteContactInfo_V3(ByVal vCardFileName As String, ByVal inpCardFullName As String, ByRef inpPhoneNumbers() As String, ByRef inpPhoneLabels() As String, ByVal inpPhoneCount As Integer,
                                                               Optional ByVal tmpImage As String = "", Optional ByVal inpCardEMailAddress As String = "", Optional ByVal inpCompanyName As String = "", Optional ByRef inpAddress() As String = Nothing)
                      
                              On Error Resume Next
                              'inpPhoneLabels should be one of:  WORK HOME CELL
                      
                              'if vCardFile does not exist, create.
                              'otherwise, append to existing file.
                      
                              Dim hFile As IntPtr, fLen As Long
                              If IO.File.Exists(vCardFileName) = False Then
                                  hFile = FileAPI_OpenFile(vCardFileName, True)
                                  fLen = FileAPI_GetFileSize(hFile)
                              Else
                                  hFile = FileAPI_OpenFile(vCardFileName, False)
                                  fLen = FileAPI_GetFileSize(hFile)
                                  FileAPI_SetFileOffset(hFile, fLen)
                      
                                  'could check last two bytes of file to ensure it has EOL (CrLf).
                                  'or could always add CrLf just to be safe.  I don't think an extra blank line would break anything in a VCF file.
                      
                                  'DO NOT USE THIS WITHOUT CONSIDERING THE POSSIBILITY THAT THE CONTACT ALREADY EXISTS IN THE EXISTING VCF FILE.
                              End If
                      
                              'write out the easy stuff.
                      
                              Dim lineStr As String = ""
                              Dim lineBytes(0 To 0) As Byte
                              Dim inpImage As Bitmap = Nothing
                      
                              'begin VCard entry.
                              lineStr = "BEGIN:VCARD" & vbCrLf
                              lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                              FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                      
                              'specify version.
                              lineStr = "VERSION:3.0" & vbCrLf
                              lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                              FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                      
                              'can do ORG: for company name.
                              If inpCompanyName <> "" Then
                                  'lineStr = "ORG:" & inpCompanyName & vbCrLf
                                  lineStr = "ORG;CHARSET=UTF-8:" & inpCompanyName & vbCrLf
                                  lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                                  FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                              End If
                      
                              'add name.  might need to do something with semi-colons for format:  last;first;additional;prefix;suffix
                              Dim nLast As String = "", nFirst As String = "", nAdditional As String = "", nPrefix As String = "", nSuffix As String = ""
                              VCard_SeparateNameParts(inpCardFullName, nLast, nFirst, nAdditional, nPrefix, nSuffix)
                              Dim inpCardName As String = nLast & ";" & nFirst & ";" & nAdditional & ";" & nPrefix & ";" & nSuffix
                              'lineStr = "N:" & inpCardName & vbCrLf
                              lineStr = "N;CHARSET=UTF-8:" & inpCardName & vbCrLf
                              lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                              FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                      
                              'add full name.
                              'lineStr = "FN:" & inpCardFullName & vbCrLf
                              lineStr = "FN;CHARSET=UTF-8:" & inpCardFullName & vbCrLf
                              lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                              FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                      
                              'add all phone numbers (with labels if present).
                              Dim i As Integer
                              For i = 0 To inpPhoneCount - 1
                      
                                  If inpPhoneLabels(i) <> "" Then
                                      inpPhoneLabels(i) = UCase(inpPhoneLabels(i))
                                      lineStr = "TEL;TYPE=" & inpPhoneLabels(i) & ":" & inpPhoneNumbers(i) & vbCrLf
                                  Else
                                      lineStr = "TEL:" & inpPhoneNumbers(i) & vbCrLf
                                  End If
                      
                                  lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                                  FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                              Next i
                      
                              'can do ADR: address.
                              For i = 0 To inpPhoneCount - 1
                                  If inpAddress(i) <> "" Then 'ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
                                      inpPhoneLabels(i) = UCase(inpPhoneLabels(i))
                                      lineStr = "ADR;TYPE=" & inpPhoneLabels(i) & ":;;" & inpAddress(i) & vbCrLf
                                      lineStr &= "LABEL;TYPE=" & inpPhoneLabels(i) & ":" & inpAddress(i) & vbCrLf
                                      lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                                      FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                                  End If
                              Next i
                      
                              'add email address if present.
                              If inpCardEMailAddress <> "" Then
                                  lineStr = "EMAIL:" & inpCardEMailAddress & vbCrLf
                                  lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                                  FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                              End If
                      
                            If tmpImage <> "" Then
                      
                                  inpImage = CType(Image.FromFile(tmpImage, True), Bitmap)
                                  If inpImage.Width > 0 And inpImage.Height > 0 Then
                                      'resize to 96x96 ?
                      
                                      Dim newImage As New Bitmap(inpImage, 96, 96)
                                      Dim newImageGfx As Graphics
                                      newImageGfx = Graphics.FromImage(newImage)
                                      newImageGfx.DrawImage(inpImage, New Rectangle(0, 0, 96, 96))
                      
                      
                                      'save image to stream.
                                      Dim imgStream As New IO.MemoryStream()
                                      newImage.Save(imgStream, Imaging.ImageFormat.Jpeg)      'could also do PNG, but must change encoding type below!
                      
                                      'get stream bytes.
                                      Dim imgBytes(0 To 0) As Byte
                                      ReDim imgBytes(0 To CInt(imgStream.Length - 1))
                                      imgStream.Position = 0
                                      imgStream.Read(imgBytes, 0, CInt(imgStream.Length))
                      
                                      'close and dispose objects.
                                      imgStream.Close()
                                      imgStream.Dispose()
                                      newImageGfx.Dispose()
                                      newImage.Dispose()
                      
                                      'encode to base64.
                                      Dim imgBase64str As String = ""
                                      imgBase64str = Convert.ToBase64String(imgBytes)
                      
                                      'add the line header stuff.
                                      lineStr = "PHOTO;ENCODING=B;TYPE=JPEG:" & imgBase64str
                      
                                      'after 253 chars, insert CRLF and space.
                      
                                      i = 74
                                      Dim tempLeftPart As String = "", tempRightPart As String = ""
                                      Do
                                          If i > Len(lineStr) Then Exit Do
                      
                                          tempLeftPart = Strings.Left(lineStr, i)
                                          tempRightPart = Strings.Mid(lineStr, i + 1)
                      
                                          lineStr = tempLeftPart & vbCrLf & " " & tempRightPart
                      
                                          i = i + 76
                      
                                      Loop
                      
                                      lineStr = lineStr & vbCrLf & vbCrLf
                      
                                      lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                                      FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                      
                                  End If
                      
                              End If
                      
                      
                              lineStr = "END:VCARD" & vbCrLf
                              lineBytes = System.Text.Encoding.UTF8.GetBytes(lineStr)
                              FileAPI_PutBytes(hFile, -1, lineBytes.Length, lineBytes)
                      
                              FileAPI_CloseFile(hFile)
                      
                          End Sub
                      I use the code like that:
                      Code:
                          Public Sub BlueSoleil_PBAP_CreateNewContactAsVcard(name As String, number As String, label As String, count As Integer,
                                                                             Optional picture As String = "", Optional mail As String = "",
                                                                             Optional compagny As String = "", Optional address As String = "")
                              Try
                                  Dim newnumber(0 To count - 1) As String
                                  Dim newlabel(0 To count - 1) As String
                                  Dim newaddress(0 To count - 1) As String
                                  newnumber(0) = number
                                  newlabel(0) = label
                                  newaddress(0) = address
                                  VCard_WriteContactInfo_V3(MainPath & "NewVcard.vfc", name, newnumber, newlabel, count - 1, picture, mail, compagny, newaddress)
                              Catch ex As Exception
                                  MessageBox.Show(ex.Message)
                              End Try
                      
                          End Sub
                      Code:
                      BlueSoleil_PBAP_CreateNewContactAsVcard(addNewContactName, addNewContactId, "HOME", 1, MainPath & "Photo\pig.jpg", "pipo\gmail.pipo", "mycompagny", "myaddress")
                      But i don't know how to save this new contact into the phone !!!!!!!!!!!!!
                      Last edited by pierrotm777; 03-11-2016, 09:54 AM.

                      Comment


                      • #13
                        Just adding a large "on error resume next" is not the ideal solution. We need to identify the line causing the error and correct the logic.

                        To send a vcard to the phone, I believe it will require using the OPP (Object Push) Profile. I can probably do it this weekend.

                        Comment


                        • #14
                          Originally posted by ClockWorK View Post
                          Just adding a large "on error resume next" is not the ideal solution. We need to identify the line causing the error and correct the logic.
                          I am ok with you , but i have found only this solution for now !
                          I send you my last code as soon as possible !

                          Comment


                          • #15
                            I've got Obex Push working. I can compose a vcard, and push it to the phone. The phone shows a confirmation to receive the file. I click "yes". The vcard (.vcf) is transferred to the phone. However, the phone asks me which app to use to open the VCF file. If I choose "Contacts" then the vcard gets imported to my contacts. If I choose some other app, it doesn't get imported.

                            I cannot pull the default vcard from the phone. I get an Access Denied error. Not a big deal, since the first entry in the phonebook should always be the vcard for the phone itself.

                            I will look at the vcard "multiple phone/address" problem tomorrow.


                            Comment

                            Working...
                            X