totalcross.io.sync
Class Conduit

totalcross.lang.Object
  extended by totalcross.ui.gfx.GfxSurface
      extended by totalcross.ui.Control
          extended by totalcross.ui.Container
              extended by totalcross.ui.Window
                  extended by totalcross.ui.MainWindow
                      extended by totalcross.io.sync.Conduit
All Implemented Interfaces:
MainClass

public abstract class Conduit
extends MainWindow

This class allows you to automatically synchronize files between your device and the desktop. Currently it supports only WinCE and PalmOS devices, and desktops with Windows 2000+. It is also required that you have installed the synchronization software provided by the device manufacturer. (Refer to the TotalCross Companion for more details)

This is the conduit's MainWindow. Two methods will be called at different times:


Field Summary
protected  String conduitName
           
 int syncTarget
          Defines the target platform for synchronization.
protected  String targetApplicationId
           
protected  String targetAppPath
           
static int TARGETING_ALL
           
static int TARGETING_PALMOS
           
static int TARGETING_WINCE
           
 
Fields inherited from class totalcross.ui.MainWindow
timers
 
Fields inherited from class totalcross.ui.Window
_controlEvent, _dragEvent, _draggingEvent, _focus, _keyEvent, _penEvent, beepIfOut, blocking, borderStyle, cancelPenUp, canDrag, dragEventTime, dragThreshold, fadeOtherWindows, fadeValue, firstFocus, flickEnabled, flickHighSpeedDecay, flickInitialInverval, flickLowSpeedDecay, flickPixelThresholdHoriz, flickPixelThresholdVert, flickSpeedLowBound, flickStartThreshold, flickTimer, gradientTitleEndColor, gradientTitleStartColor, highlighted, highResPrepared, HORIZONTAL_GRADIENT, ignoreEventOfType, isFlicking, lastSwappedContainer, mainSwapContainer, menubar, needsPaint, NO_BORDER, popped, RECT_BORDER, ROUND_BORDER, rTitle, SIP_BOTTOM, SIP_DISABLE_NUMERICPAD, SIP_ENABLE_NUMERICPAD, SIP_HIDE, SIP_SHOW, SIP_TOP, TAB_BORDER, TAB_ONLY_BORDER, title, titleColor, titleFont, topMost, triggeredFlickDirection, VERTICAL_GRADIENT, zStack
 
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, nextTransitionEffect, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_NONE, TRANSITION_OPEN, transitionEffect
 
Fields inherited from class totalcross.ui.Control
AFTER, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, CENTER, CENTER_OF, clearValueInt, clearValueStr, enabled, enableUpdateScreen, FILL, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, foreColor, height, isHighlighting, KEEP, LEFT, onEventFirst, parent, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, setFont, setH, setRel, setW, setX, setY, TOP, transparentBackground, uiCE, uiFlat, uiPalm, uiVista, visible, width, WILL_RESIZE, x, y
 
Constructor Summary
Conduit(String conduitName, String targetApplicationId, String targetAppPath, byte style)
          Creates a conduit with a title and a border.
 
Method Summary
protected abstract  void doConfig()
          Called when the user wants to configure this conduit.
protected abstract  void doSync()
          Called when the synchronization is started.
 void initUI()
          A commandline parameter must be passed in order to invoke actions on this conduit:
/r{target platform} register conduit.
static boolean isSyncingEnabled()
          Returns wether the conduit is enabled or not.
static void log(String text)
          When synchronizing PalmOS devices, logs the given text on the HotSync log.
 void onEvent(Event e)
          Called to process key, pen, control and other posted events.
protected  void onRegister()
          Called when the conduit is registered.
protected  void onUnregister()
          Called when the conduit is unregistered.
static void setConduitRect(int x, int y, int w, int h, boolean config)
          Sets the conduit's position and size when it is opened.
static void setSyncingEnabled(boolean enable)
          Enables or disables the conduit execution.
static void yield()
          This method lets the conduit manager take a breath.
 
Methods inherited from class totalcross.ui.MainWindow
_onTimerTick, addTimer, addTimer, appEnding, appStarting, exit, getCommandLine, getDefaultFont, getMainWindow, minimize, onExit, onMinimize, onRestore, removeTimer, restore, setDefaultFont, setRect, setUIStyle
 
Methods inherited from class totalcross.ui.Window
_doPaint, _postEvent, destroyZStack, drawHighlight, getBorderStyle, getClientRect, getClientRect, getFocus, getHighlighted, getPreferredHeight, getPreferredWidth, getTitleFont, getTopMost, handleFocusChangeKeys, isFlickEnabled, isFlicking, isTopMost, isVisible, loadBehind, makeUnmovable, onClickedOutside, onPopup, onUnpop, paintTitle, popup, popupMenuBar, popupNonBlocking, postPopup, postPressedEvent, postUnpop, pumpEvents, releaseFlickTimer, removeFocus, repaintActiveWindows, resize, resizeHeight, resizeWidth, screenResized, setBorderStyle, setDeviceTitle, setFlickEnabled, setFocus, setGrabPenEvents, setHighlighted, setMenuBar, setSIP, setTitle, setTitleFont, swap, swapFocus, unpop, validate
 
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, broadcastEvent, clear, findChild, findNearestChild, findNextFocusControl, getChildren, getFocusableControls, getInsets, incLastX, incLastY, onAddAgain, onColorsChanged, onPaint, onRemove, paintChildren, remove, removeAll, setEnabled, setHighlighting, setInsets, swapToTopmostWindow
 
Methods inherited from class totalcross.ui.Control
_onEvent, addFocusListener, addGridListener, addHighlightListener, addKeyListener, addPenListener, addPressListener, addTimer, addTimer, addTimerListener, addWindowListener, changeHighlighted, contains, getAbsoluteRect, getBackColor, getEventListeners, getFont, getForeColor, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getWidth, getX, getX2, getY, getY2, handleGeographicalFocusChangeKeys, isDisplayed, isEnabled, isInsideOrNear, isVisibleAndInside, onBoundsChanged, onFontChanged, onWindowPaintFinished, postEvent, removeFocusListener, removeGridListener, removeHighlightListener, removeKeyListener, removePenListener, removePressListener, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, requestFocus, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setVisible, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary
 
Methods inherited from class totalcross.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface totalcross.MainClass
_postEvent
 

Field Detail

TARGETING_WINCE

public static final int TARGETING_WINCE
See Also:
Constant Field Values

TARGETING_PALMOS

public static final int TARGETING_PALMOS
See Also:
Constant Field Values

TARGETING_ALL

public static final int TARGETING_ALL
See Also:
Constant Field Values

syncTarget

public int syncTarget
Defines the target platform for synchronization. Note that changing this value has no effects.

See Also:
TARGETING_WINCE, TARGETING_PALMOS, TARGETING_ALL

conduitName

protected String conduitName

targetApplicationId

protected String targetApplicationId

targetAppPath

protected String targetAppPath
Constructor Detail

Conduit

public Conduit(String conduitName,
               String targetApplicationId,
               String targetAppPath,
               byte style)
Creates a conduit with a title and a border. This is the only constructor that your MainWindow class may call.

Method Detail

initUI

public final void initUI()
A commandline parameter must be passed in order to invoke actions on this conduit:
/r{target platform} register conduit.
/u{target platform} unregister conduit.
/s{target platform} synchronize.
/c configure.
Where {target platform} may be one of the following:
p - targets PalmOS.
w - targets WinCE.
a - targets all supported platforms.

Overrides:
initUI in class Container

onEvent

public void onEvent(Event e)
Description copied from class: Control
Called to process key, pen, control and other posted events.

Overrides:
onEvent in class Control
Parameters:
e - the event to process
See Also:
Event, KeyEvent, PenEvent

log

public static void log(String text)
When synchronizing PalmOS devices, logs the given text on the HotSync log.
When synchronizing other devices, the text is logged on the DebugConsole instead.


yield

public static void yield()
This method lets the conduit manager take a breath. This is important, because the connection between the device and the desktop might be lost during long operations.


doSync

protected abstract void doSync()
Called when the synchronization is started. The whole synchronization done from this method.


doConfig

protected abstract void doConfig()
Called when the user wants to configure this conduit.


setSyncingEnabled

public static void setSyncingEnabled(boolean enable)
Enables or disables the conduit execution.

Note that disabling a conduit is NOT the same as unregistering.


isSyncingEnabled

public static boolean isSyncingEnabled()
Returns wether the conduit is enabled or not.


setConduitRect

public static void setConduitRect(int x,
                                  int y,
                                  int w,
                                  int h,
                                  boolean config)
Sets the conduit's position and size when it is opened. You can remove the window from screen by using a x value like 10000. Default values are -2,-2,240,320. You should call this method in the onRegister method, inherited by your conduit.
This is a sample that sets the screen size to be the same of "/scr palmhi" when running in the desktop:
 setConduitRect(-2,-2,320,320,false);
 

Parameters:
x - Absolute position on screen, or -1 to use default, or -2 to center.
y - Absolute position on screen, or -1 to use default, or -2 to center.
w - The width of the window (usually 240 or 320)
h - The height of the window (usually 320)
config - If true, you are passing the bounds for when the config is being called; if false, is the bounds used when synchronizing.
Since:
TotalCross 1.01

onRegister

protected void onRegister()
Called when the conduit is registered. Placeholder, does nothing by default.

Since:
TotalCross 1.01

onUnregister

protected void onUnregister()
Called when the conduit is unregistered. Placeholder, does nothing by default.

Since:
TotalCross 1.01