I'm trying to add an implementation of CeSHCreateShortcut to librapi.
I've followed the template of the other functions in
file_management.c, but it's not working.  The marshalled data
structure seems to be correct and send OK, but when waiting for a
response, the poll() in synce_socket_wait() returns an error
indicating that the connection has hung up (pfd.revents == 0x19 ==
POLLIN | POLLERR | POLLHUP).

I'm not really sure how to debug this any further.  Does anybody with
a better knowledge of RAPI have any suggestions?

My PDA, a Dell Axim X50, has its buttons hooked up to various
shortcuts, so I'm trying to change what one of those buttons does via
RAPI.  I'm trying to do this to 25 PDAs, and I expect I'll reconfigure
them to do something different later, which is why I'm trying to do it
with a program instead of manually.

This is my implementation:

BOOL CeSHCreateShortcut(
  LPCWSTR lpszShortcut,
  LPCWSTR lpszTarget)
{
  RapiContext* context = rapi_context_current();
  BOOL return_value = 0;
  
  synce_trace("Creating shortcut");
  
  rapi_context_begin_command(context, 0x30);
  rapi_buffer_write_string(context->send_buffer, lpszShortcut);
  rapi_buffer_write_string(context->send_buffer, lpszTarget);

  if ( !rapi_context_call(context) )
    goto exit;
  
  rapi_buffer_read_uint32(context->recv_buffer, &context->last_error);
  rapi_buffer_read_uint32(context->recv_buffer, &return_value);

 exit:
  return return_value;
}

This is my test program:

#include <rapi.h>
#include <synce_log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>

int main(int argc, char** argv)
{
  int result = 0;
  RapiConnection* connection = NULL;
  HRESULT hr;
  int c;
  char *devPath = NULL;
  
  while ( (c = getopt(argc, argv, "p:")) != -1 )
  {
    switch(c)
    {
      case 'p':
        devPath = optarg;
        break;
        
      default:
        fprintf(stderr,"Unrecognized command-line option\n");
        exit(1);
    }
  }

  connection = rapi_connection_from_path(devPath);
  rapi_connection_select(connection);
  hr = CeRapiInit();

  if (FAILED(hr))
  {
    fprintf(stderr, "%s: Unable to initialize RAPI: %s\n", 
            argv[0],
        synce_strerror(hr));
    result = 1;
    goto exit;
  }
  BOOL res = CeSHCreateShortcut(wstr_from_current(argv[optind]),
  wstr_from_current(argv[optind+1]));
  if (!res)
  {
    fprintf(stderr, "%s: Unable to create shortcut to '%s' at '%s':
  %s\n",
            argv[0],argv[optind+1],argv[optind],
        synce_strerror(hr));
    result = 1;
    goto exit;
  }

 exit:
  CeRapiUninit();
  rapi_connection_destroy(connection);
  
  return result;
}

When I run it, I get this output:

[CeSHCreateShortcut:426] Creating shortcut
[rapi_context_call:213] result 2 = 0x80004005
[rapi_buffer_read_data:342] unable to read 4 bytes. read_index=8, bytes_used=8
[rapi_buffer_read_data:342] unable to read 4 bytes. read_index=8, bytes_used=8
./pshortcut: Unable to create shortcut to '\Windows\iexplore.exe' at 
'\Shortcut.lnk': Success

Thanks for any suggestions!

----Scott.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Synce-devel mailing list
Synce-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synce-devel

Reply via email to